Rerunning failed tests using IRetryAnalyzer,ITestResult in TESTNG

Rerunning failed tests using IRetryAnalyzer,ITestResult in TESTNG



TESTNG is a java framework used by JAVA Developers to perform unit testing of their code.
We can even use TESTNG for Selenium to automate the manual testcases and verify the output by inserting
the Soft Assertions and Hard Assertions. TESTNG generates the reports once the testcase run completed.
It generates the test-output directory with results in index.html and emailable-report.html. It also generates the testng-failed.xml for the tests which are failed in the Suite. Now it is possible to re-run the failed tests.
Mostly the Selenium tests will fail due to multiple reasons, one of them is NoSuchElementException this occurs due to TimeOut Issues where the element takes time to display. In those cases it would be good to re-run and fix the issues.

Steps for Implementing the Retry Logic:

1. IRetryAnalyzer is an interface which has to be implemented the Class RerunTests.java.




2. Write the TestNG Testcase that has to be re-run. Use TESTNG attribute retryAnalyzer and provide the value for the attribute as RerunTests.java.

3. Finally the failed testcase executes as per the retryCount mentioned in the RerunTests.java.

Rerun Failed Tests using Retry Logic

Rerun Failed Tests using Retry Logic

Leave a Reply

Your email address will not be published. Required fields are marked *