I have used IRetryAnalyzer to re-run my failed test cases. I have also used IAnnotationTransformer as the TestNg Listener. Now only the last count of the re runned test case is coming as failed in the report. The previous iterations are coming as skipped. I want all the iteration should come as failed in the report.
Below are codes for the 2 classes:
For IAnnotationTransformer:
package com.TestNG;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import org.testng.IAnnotationTransformer;
import org.testng.IRetryAnalyzer;
import org.testng.annotations.ITestAnnotation;
public class RetryListener implements IAnnotationTransformer {
@Override
public void transform(ITestAnnotation testannotation, Class testClass,
Constructor testConstructor, Method testMethod) {
IRetryAnalyzer retry = testannotation.getRetryAnalyzer();
if (retry == null) {
testannotation.setRetryAnalyzer(Retry.class);
}
}
}
For IRetryAnalyzer :
package com.TestNG;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;
public class Retry implements IRetryAnalyzer {
private int retryCount = 0;
private int maxRetryCount = 2;
@Override
public boolean retry(ITestResult result) {
if (retryCount < maxRetryCount) {
retryCount++;
return true;
}
return false;
}
}
Result : Screenshot