I did search a lot and this is the closest answer that I got but does not solve my problem. TestNG retrying failed tests doesn't output the correct test results
But I need the above problem to extend from TestNG onto Maven. Please help.
My Project stack: TestNG, Maven surefire plugin, Maven. I am running the tests from command line - "mvn clean compile test". I am using a retryanalyzer to re-run the failed tests, that are passing the second time. I have been able to use a CustomListener to update the results stored in the TestNG's testcontext (based on solutions in stackoverflow). This was confirmed when I ran the tests as TestNG suite.
But when I run "mvn clean compile test", all the retries are counted as separate tests and build always fails. How do I make TestNG send only the final Suite results to Maven Surefire plugin ?
TESTNG EXECUTION:
============================================
DefaultTest
Total tests run: 4, Failures: 2, Skips: 0
============================================
============================================
DefaultSuite
Total tests run: 2, Failures: 0, Skips: 0
============================================
MAVEN EXECUTION:
Tests run: 4, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.292 sec <<< FAILURE!
Results :
Failed tests:
test1(foo.TestClass1)
test1(foo.TestClass1)
Tests run: 4, Failures: 2, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
The build passed because of the retry. How do I reflect the TestNG retry Suite results onto Maven ?