When changing the Spring Boot 2.2 application to 2.5.5 with JDK 17, the Surefire test plugin does not start any existing tests. This is the message:
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Why does it not start any existing tests? The names of the tests are *Test.java.
I saw similar behavior when explicitly adding the Surefire plugin with a version higher then 2.19. Spring boot test starter will have a newer surefire plugin.
Maven version is 3.6.3. On the path is jdk17.1.0.
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
I looked at similar questions and saw that the path of the test folder should be below 'src'. Yes, it is.
In the folder it is the same:
Below both folders is a 'java' folder.
The Surefire is not explicitly in the pom.xml because it is in the spring-boot-test starter.
CodePudding user response:
what kind of test exist in you project ? integration test or/and unit test? Can you give more detail on your context?
Anyway, from version 2.4.0 of spring-boot, JUnit 5’s Vintage Engine Removed from spring-boot-starter-test.
It is said in the 2.4.0 release note page https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.4-Release-Notes :
If you upgrade to Spring Boot 2.4 and see test compilation errors for JUnit
classes such as org.junit.Test, this may be because JUnit 5’s vintage engine has been
removed from spring-boot-starter-test. The vintage engine allows tests written with
JUnit 4 to be run by JUnit 5. If you do not want to migrate your tests to JUnit 5 and
wish to continue using JUnit 4, add a dependency on the Vintage Engine, as shown in
the following example for Maven:
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>