4

We are using Maven for script execution. For reporting we have used TestNG. In case test failed for first time we want to re execute those failed tests again. Is there any option available?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
amogh
  • 117
  • 8
  • 1
    Maven Surefire provide [this](https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#rerunFailingTestsCount) option to re-run failed tests, but only for JUnit apparently – A_Di-Matteo Mar 10 '16 at 09:17
  • After failing test you will get a failed test suite in your report directory, Call again this suite file in your maven again – Sadik Ali Mar 10 '16 at 09:56
  • 1
    This will be of interest http://stackoverflow.com/questions/25781098/is-there-anyway-to-rerun-a-test-class-when-it-fails – Tunaki Mar 10 '16 at 09:57
  • 1
    In case of TestNG when suite execution fails we are deleting all files inside reporting folder. We need to move it to some other folder and again need to pass it as a input to the maven. – amogh Apr 26 '16 at 11:13

1 Answers1

1

Implement IRetryAnalyzer interface to rerun failed test cases with a count to re execute. Add @Test(retryAnalyzer=<classname>) to test case.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Sonali
  • 26
  • 2