Friday, May 8, 2015

Retry Failed Tests in TestNG

TestNG provides various listeners to customize our needs. One such powerful listener is IRetryListener using which you can retry a test case multiple times before declaring it as Failed.

If you see a failure can just automatically rerun the test to make sure that the test is consistently failing. this way it reduces false failures because of random issues and you spend more time debugging true failures.

IRetryListener interface has only one method public boolean retry(ITestResult result);

This method will be called whenever a test method fails. You can get the details of the test from ITestResult input argument to this method. This method implementation should return true if you want to re-execute your failed test and false if you don't want to re-execute your test.

No comments:

Post a Comment

Selenium 3 vs Selenium 4