Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如果testNG中的before/aftermethod失败或跳过,重试将不会继续?_Java_Testng - Fatal编程技术网

Java 如果testNG中的before/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

我通过实现IRetryAnalyzer对重试机制进行编码。刚刚发现,如果beforemethod/aftermethod出现异常,重试机制将无法工作,这是作为设计还是我的代码问题

   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;
  }
}

有人注意到这个问题吗…?你能在?完成,请检查,有人注意到这个问题吗…?你能在?完成,请检查,