重做失败的case是常用的操作
实现方法1 - 使用RetryAnalyzerCount,此类继承自IRetryAnalyzer
import org.testng.ITestResult;
import org.testng.util.RetryAnalyzerCount;
/**
* An implementation of IRetryAnalyzer that allows you to specify the maximum
* number of times you want your test to be retried.
*/
public class TestngRetry extends RetryAnalyzerCount {
public TestngRetry() {
// set retry count
setCount(1);
}
@Override
public boolean retryMethod(ITestResult result) {
System.out.println("Retrying...");
return !result.isSuccess();
}
}
需在@Test注解中标注使用
@Test(description = "xxx2", retryAnalyzer = TestngRetry.class)
实现方法2 - 自定义retry类继承IRetryAnalzer
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;
public class TestngRetry implements