Search code examples
eclipsejunit4junit5

Why is Eclipse trying to use JUnit5 when it should use JUnit4?


I'm just going through a tutorial which is a Maven project in Eclipse, and it should run some tests using JUnit4, so I have put this dependency in the POM:

<dependency>    
  <groupId>junit</groupId>      
  <artifactId>junit</artifactId>    
  <version>4.13</version>       
  <scope>test</scope> 
</dependency>

Still, trying to run the tests I get the following: No tests found with testrunner 'JUnit5'

Why is Eclipse not using JUnit4 when this is the only dependency given in the project?


Solution

  • Because in the run configuration you have chosen JUnit 4 as Test Runner, Eclipse uses JUnit 4 instead of JUnit 5 to run this test.

    Please note that even though Eclipse preselects the matching Test Runner for new run configurations, it does not change the Test Runner for existing run configurations.