I have created some JUnit test cases as per below hierarchy.
Package name e.g :
test.qa.paramter.myTest
Under this package, i have 2 test cases:
1: First Test case(with class name NormalTest and method name as caseNormalTest) with @Test annotation
2: And second test case (with class name RepeatTest and methods name as caseRepeatTest) with @RepeatedTest which will repeat the same test 2 times with different input values.
my question is how i can get the same classname xml output for @RepeatedTest as its not displaying the full package name. Also is it possible to get the repetition count in the surefire report?
Now when i run the test case using Jenkins, maven-surefire-plugin generate the test result xml for @RepeatedTest
<testcase name="caseRepeatTest" classname="caseRepeatTest()" time="30.636"/>
<testcase name="caseParametrization" classname="caseParametrization()" time="13.013"/>
whereas for @Test annoation i m getting
<testcase name="caseNormalTest" classname="test.qa.paramter.myTest.NormalTest" time="22.796"/>
below is my POM setting
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<argLine>-Xms512m -Xmx2048m</argLine>
<testFailureIgnore>true</testFailureIgnore>
<systemPropertyVariables>
<sun.net.http.allowRestrictedHeaders>true</sun.net.http.allowRestrictedHeaders>
<testInstance>v1</testInstance>
</systemPropertyVariables>
<includes>
<include></include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.2</version>
</dependency>
</dependencies>
</plugin>
Upgrade to Maven Surefire 2.22.0 or higher and remove the dependency on the obsolete junit-platform-surefire-provider
.
Details here: https://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven