コード例 #1
0
 /**
  * Get All tests id by class + method + parameters hash code.
  *
  * @param context
  * @param suite
  * @author kevinkong
  */
 private void getAllTestIds(ITestContext context, ISuite suite) {
   IResultMap passTests = context.getPassedTests();
   IResultMap failTests = context.getFailedTests();
   List<IInvokedMethod> invokedMethods = suite.getAllInvokedMethods();
   for (IInvokedMethod im : invokedMethods) {
     if (passTests.getAllMethods().contains(im.getTestMethod())
         || failTests.getAllMethods().contains(im.getTestMethod())) {
       int testId = getId(im.getTestResult());
       // m_out.println("ALLtestid=" + testId);
       allRunTestIds.add(testId);
     }
   }
 }
コード例 #2
0
  /**
   * Since the methods will be sorted chronologically, we want to return the ITestNGMethod from the
   * invoked methods.
   */
  private Collection<ITestNGMethod> getMethodSet(IResultMap tests, ISuite suite) {
    List<IInvokedMethod> r = Lists.newArrayList();
    List<IInvokedMethod> invokedMethods = suite.getAllInvokedMethods();

    // Eliminate the repeat retry methods
    for (IInvokedMethod im : invokedMethods) {
      if (tests.getAllMethods().contains(im.getTestMethod())) {
        int testId = getId(im.getTestResult());
        if (!testIds.contains(testId)) {
          testIds.add(testId);
          r.add(im);
        }
      }
    }
    Arrays.sort(r.toArray(new IInvokedMethod[r.size()]), new TestSorter());
    List<ITestNGMethod> result = Lists.newArrayList();

    // Add all the invoked methods
    for (IInvokedMethod m : r) {
      result.add(m.getTestMethod());
    }

    // Add all the methods that weren't invoked (e.g. skipped) that we
    // haven't added yet
    // for (ITestNGMethod m : tests.getAllMethods()) {
    // if (!result.contains(m)) {
    // result.add(m);
    // }
    // }

    for (ITestResult allResult : tests.getAllResults()) {
      int testId = getId(allResult);
      if (!testIds.contains(testId)) {
        result.add(allResult.getMethod());
      }
    }

    return result;
  }