The unusual Popup Message “No tests found with test runner ‘JUnit5’ ” is often seen when running test classes in spring boot application
In eclipse, when you run the JUnit test case in your spring boot application, some time you’ll encounter a problem that eclipse can’t find any tests. In this case, eclipse will send a popup message saying “No tests found with test runner ‘JUnit5’ “. There are a few steps you need to follow to fix this issue. In this post, we’re going to discuss this popup message.
Issue
The below popup message will be seen when you run JUnit test case

Root Cause
In eclipse, when you run the JUnit test case in your spring boot application, JUnit will not be able to find any test method in the test class. In this situation, the eclipse will display a popup message “No tests found with the JUnit5 test runner.” Junit needs at least one test method to start. The test method is created using the @Test annotation.
How to reproduce this issue
Create a test class in your spring boot application without a test method. The following example shows how this issue can be reproduced.
package com.yawintutor;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
class SpringUnitTestApplicationTests {
void contextLoads() {
}
}
Solution 1
Spring boot test class must have at least one test java method. The test methods will have annotation @Test. In the example above, there is no test method in the spring boot test class. Add @Test annotation to the method to resolve this issue
package com.yawintutor;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
class SpringUnitTestApplicationTests {
@Test
void contextLoads() {
}
}
Solution 2
The maven may sometimes not download all the dependent jar files from the downloadable websites because of various reason such as unavailability of the site or slow download speed etc. The maven dependency may not be added properly in your spring boot project. Update the maven dependency by using the below command
Select your spring boot project name in Package Explorer
Right Click
Select Maven
Update Project
Solution 3
The spring boot test dependency must be included in the pom.xml file. This dependency will add all the test jar files needed to the class path of the project test runtime environment. Check the JUnit jar dependency in your pom.xml. The dependency should look like the below.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
Solution 4
When developing spring boot application, the java classes are often compiled when you save the file. Due to an incorrect synchronization between saving the java class and the compilation process, some error could occur in the compiled classes. Rebuild your spring boot application again. In this step, if any issues in your compiled class are deleted and re-created. Follow the steps below.
Goto Menu -> Select Project Menu -> Clean
Goto Menu again -> Select Project Menu -> Build Project (if Build Automatically menu is selected, then Build Project will be disabled. In this case ignore this step)
Solution 5
The last execution of the program is stored as a history by Eclipse / Spring Boot Tool Suite. When you run from the the tool bar, it will execute from the history. If run history is already set with the project, it may cause issue. Follow the steps below to delete from the history. Run the spring boot application again, which will execute from the new java environment.
Select your spring boot project name in Package Explorer
Right Click
Select "Run As"
Select "Run Configurations" in the sub menu
It will open a popup window
Select JUnit in the left panel
Select the project entries under JUnit
Right click on the project name and click delete
5 Comments