Reputation: 33
I want to use maven-surefire-plugin (version 2.18.1) to rerun failing junit (version 4.12) tests (http://maven.apache.org/surefire/maven-surefire-plugin/examples/rerun-failing-tests.html). According to documentation - I set rerunFailingTestsCount property and when test fails, it is executed again, but on the console I get (e.g. first time test failed, second time - passed):
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.299 sec <<< FAILURE! - in sth.sth.ReRunTest
someRerunTest(sth.sth.ReRunTest) Time elapsed: 1.779 sec <<< FAILURE!
java.lang.AssertionError: expected null, but was:<sth>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotNull(Assert.java:755)
at org.junit.Assert.assertNull(Assert.java:737)
at org.junit.Assert.assertNull(Assert.java:747)
at sth.sth.ReRunTest(ReRunTest.java:14)
but it should be:
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Flakes: 1
Should I set anything else in the surefire configuration?
Upvotes: 2
Views: 2136
Reputation: 109
Please, use junit 4.11 and maven-surefire-plugin 2.19.
I don't know the exact minimum version.
mvn -Dsurefire.rerunFailingTestsCount=2 test
-> Tests run: 12, Failures: 1, Errors: 0, Skipped: 1, Flakes: 2
Upvotes: 0