'Spring Boot 2.5+ with JDK 17 - maven surefire doesn't execute existing tests
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.
Solution 1:[1]
Other situations what you will see no tests run:
Main and test are not in the same folder
Test file names do not end in *Test.java
There is an older surefire plugin, like 2.14.x. Just use a newer version, like
org.apache.maven.plugins maven-surefire-plugin 3.0.0-M5
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tm1701 |


