There is a config value rerunFailingTestsCount but I want to run a test method a configurable number of times even it is successful. Are there any options?
Asked
Active
Viewed 6,609 times
3 Answers
4
I don't think it is possible to configure maven-surefire-plugin
to rerun passing tests.
However, you can configure the invocation count of a single test using the TestNG (not JUnit) @Test
annotation:
@Test(invocationCount = 5)
public void testSomething() {
}
This will result in the testSomething
method being tested 5 times.
If you don't want to go the TestNG route, you can refer to this answer for a solution with JUnit.
0
If you want to have it configurable by implementing the IInvokedMethodListener beforeInvocation method, something to the effect :
method.getTestMethod().setInvocationCount(Integer.parseInt(System.getProperty("configurablecount")));
System.getProperty can be replaced by however you want to configure it. You can also probably control which tests to set the invocation count to change by passing testnames.

niharika_neo
- 8,441
- 1
- 19
- 31
0
Yes
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>phase-1</id>
<phase>test</phase>
<configuration>
<skip>false</skip>
<!-- Phase 1 configuration -->
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
<execution>
<id>phase-2</id>
<phase>test</phase>
<configuration>
<skip>false</skip>
<!-- Phase 2 configuration -->
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Antoine Meyer
- 357
- 1
- 4
- 7