Is there a way to call the maven 'test' command that only runs the tests that failed the last time it was called?
During development, you may re-run failing tests because they are flaky. To use this feature through Maven surefire, set the rerunFailingTestsCount property to be a value larger than 0. Tests will be run until they pass or the number of reruns has been exhausted.
The Maven surefire plugin provides a test parameter that we can use to specify test classes or methods we want to execute. If we want to execute a single test class, we can execute the command mvn test -Dtest=”TestClassName”.
mvn test This command is used to run the test cases of the project using the maven-surefire-plugin .
To skip running the tests for a particular project, set the skipTests property to true. You can also skip the tests via the command line by executing the following command: mvn install -DskipTests.
Try using the surefire plugin's runOrder parameter. It doesn't look like it has an ${expression}
allowing you to change the property from the command line, so I would roll my own:
... POM stuff here....
<properties>
<!-- plugin's default value for this param -->
<surefire.test.runOrder>filesystem</surefire.test.runOrder>
</properties>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<runOrder>${surefire.test.runOrder}</runOrder>
</configuration>
</plugin>
....
Then you may choose the setting you want at the command line:
mvn -Dsurefire.test.runOrder=failedfirst test
(or package
or whatever phase you want).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With