Surefire is not picking up JUnit 4/TestNG 5 tests

If you are using any of these artifacts from Spring Enterprise Bundle repository –just like I did–, you can face this problem. Since the artifact names of these artifacts are different than usual, it is not possible for surefire to detect.

Solution is easy, just configure surefire as follows.

        This two configuration is required to make maven-surefire-plugin recognize junit and testng
        since we are using these artifacts from spring enterprise bundle repository (which has
        different artifact names than usual)

You can use mvn -X to run maven in debug mode, it is very useful, this is how I figured out the problem.

[INFO] [surefire:test {execution: default-test}]
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG]   org.apache.maven.surefire:surefire-booter:jar:2.6:runtime (selected for runtime)
[DEBUG]     org.apache.maven.surefire:surefire-api:jar:2.6:runtime (selected for runtime)
[DEBUG] Adding to surefire booter test classpath: /home/alych/.m2/repository/org/apache/maven/surefire/surefire-booter/2.6/surefire-booter-2.6.jar Scope: runtime
[DEBUG] Adding to surefire booter test classpath: /home/alych/.m2/repository/org/apache/maven/surefire/surefire-api/2.6/surefire-api-2.6.jar Scope: runtime
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG] Retrieving parent-POM: org.apache.maven.surefire:surefire-providers:pom:2.6 for project: null:surefire-junit:jar:null from the repository.

Leave a Reply

Your email address will not be published.