classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view



Question on retry logic for failed tests and following are the class files:

TestRetry class:
public class TestRetry implements IRetryAnalyzer {
int counter=0;
int retryLimit=4;

public boolean retry(ITestResult result) {
if (counter < retryLimit) {
  TestReporter.logStep("Retrying Test " +result.getName()+" for number of times: "+(counter+1));
          return true;
return false;

RetryListener class:
public class RetryListener implements IAnnotationTransformer {

public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
// TODO Auto-generated method stub
IRetryAnalyzer retry = annotation.getRetryAnalyzer();

        if (retry == null) {



Test class:

public class RetryLogicTest {
@BeforeSuite(alwaysRun = true)
public void beforeSuite(ITestContext context) {
   for (ITestNGMethod method : context.getAllTestMethods()) {
          method.setRetryAnalyzer(new TestRetry());

public void firsttest() {
TestReporter.assertEquals("Test", "Test", "pass");
@Test(priority=1, dependsOnMethods="firsttest")
public void secondtest() {
TestReporter.assertEquals("Test", "Test1", "fail");
public void thirdtest() {
TestReporter.assertEquals("Test", "Test", "pass");


when the above RetryLogicTest is run 

results are :
firsttest is passed
secondtest is failed and retried 5 times , on  5th time still it is failed
thirdtest is skipped because it depends on secontest

The above results are working as expected. 

Since the secondtest depends on firsttest, thirdtest depends on secondtest. When one of them fails, I want to execute all the tests from first again. Is there a way to do it?

So any tests fail, I want all the test from first to be executed as it depends on each test.


You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at
For more options, visit