Student Resources

Surefire is not picking up JUnit 4/TestNG 5 tests by umut.utkan on Nov. 14, 2010

By July 18, 2018 No Comments

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.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!--
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)
-->
<junitArtifactName>org.junit:com.springsource.org.junit</junitArtifactName>
<testNGArtifactName>org.testng:com.springsource.org.testng</testNGArtifactName>
</configuration>
</plugin>

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/umut/.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/umut/.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:sure

Leave a Reply