Java 如果testNG中的before/aftermethod失败或跳过,重试将不会继续?
我通过实现IRetryAnalyzer对重试机制进行编码。刚刚发现,如果beforemethod/aftermethod出现异常,重试机制将无法工作,这是作为设计还是我的代码问题Java 如果testNG中的before/aftermethod失败或跳过,重试将不会继续?,java,testng,Java,Testng,我通过实现IRetryAnalyzer对重试机制进行编码。刚刚发现,如果beforemethod/aftermethod出现异常,重试机制将无法工作,这是作为设计还是我的代码问题 public class MyRetryAnalyzer implements IRetryAnalyzer { public static int MAX_RETRY_COUNT = 3; // to avoid the thread safe issue, use the AtomicInteger
public class MyRetryAnalyzer implements IRetryAnalyzer {
public static int MAX_RETRY_COUNT = 3;
// to avoid the thread safe issue, use the AtomicInteger class, instead of Integer
AtomicInteger count = new AtomicInteger(MAX_RETRY_COUNT);
public boolean isRetryAvailable() {
return (count.intValue() > 0);
}
/**
* retry a failed test
*
* @param ITestResult result - the test result of current test case
*
* @return Returns true if the test method has to be retried, false otherwise.
*
* @author Fiona Zhang
*/
@Override
public boolean retry(ITestResult result) {
boolean retry = false;
System.out.println("result status is : ------------------------- "+result.getStatus());
if (isRetryAvailable()) {
System.out.println("Going to retry test case: " + result.getMethod() + ", "
+ (MAX_RETRY_COUNT - count.intValue() + 1) + " out of " + MAX_RETRY_COUNT);
retry = true;
// --count
count.decrementAndGet();
}
return retry;
}
}
有人注意到这个问题吗…?你能在?完成,请检查,有人注意到这个问题吗…?你能在?完成,请检查,