Java 类org.testng.annotations.ITestAnnotation 实例源码

项目:TestNG-Foundation    文件:ExecutionFlowController.java   
@Override
@SuppressWarnings("rawtypes")
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
    // if @Test for test method
    if (testMethod != null) {
        // get TestNG Foundation configuration
        TestNGConfig config = TestNGConfig.getConfig();
        // if default test timeout is defined
        if (config.containsKey(TestNGSettings.TEST_TIMEOUT.key())) {
            // get default test timeout
            long defaultTimeout = config.getLong(TestNGSettings.TEST_TIMEOUT.key());
            // if current timeout is less than default
            if (defaultTimeout > annotation.getTimeOut()) {
                // set test timeout interval
                annotation.setTimeOut(defaultTimeout);
            }
        }
    }
}
项目:testng_samples    文件:AssumeBugIsFixed.java   
@Override
public void transform(ITestAnnotation annotation, Class testClass,
    Constructor testConstructor, Method testMethod) {
  Bug bugAnnotation = testMethod.getAnnotation(Bug.class);
  if (bugAnnotation != null) {
    try {
      MantisConnectLocator mcl = new MantisConnectLocator();
      MantisConnectPortType mcp = mcl.getMantisConnectPort(
          new URL("http://localhost/mantisbt-1.2.17/api/soap/mantisconnect.php"));
      IssueData issue = mcp.mc_issue_get("administrator", "root",
          BigInteger.valueOf(bugAnnotation.value()));
      String status = issue.getStatus().getName();
      if (! ("closed".equals(status) || "resolved".equals(status))) {
        annotation.setEnabled(false);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

}
项目:seletest    文件:AnnotationTransformer.java   
@Override
@SuppressWarnings("rawtypes")
public void transform(final ITestAnnotation test, final Class testClass, final Constructor testConstructor, final Method testMethod) {

    //Set DataProvider for the test
    if (testMethod != null){
        if(dataType(testMethod)!=null) {
            if(dataType(testMethod).equals(Data.PROPERTIES)) {
                test.setDataProviderClass(DataSources.class);
                test.setDataProvider(dataPropertiesSource);
            } else if(dataType(testMethod).equals(Data.EXCEL)){
                test.setDataProviderClass(DataSources.class);
                test.setDataProvider(dataExcelSource);
            }
        }
    }

    //Set retry analyzer class for all @Test methods
    IRetryAnalyzer retry = test.getRetryAnalyzer();
    if (retry==null){
        test.setRetryAnalyzer(RetryAnalyzer.class);
    }
}
项目:Testy    文件:MyTransformer.java   
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
    Ignores ignores = testMethod.getAnnotation(Ignores.class);
    if (ignores != null) {
        for (Ignores.Driver ignore : ignores.value()) {
            if (Browser.CHROME.name().equals(ignore.name())) {
                annotation.setEnabled(false);
            } else if (Browser.FIREFOX.name().equals(ignore.name())) {
                annotation.setEnabled(false);
            } else if (Browser.IEXPLORE.name().equals(ignore.name())) {
                annotation.setEnabled(false);
            } else if ("ALL".equals(ignore.name())) {
                annotation.setEnabled(false);
            }
        }
    }
}
项目:WebAndAppUITesting    文件:RetryListener.java   
@SuppressWarnings("rawtypes")
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {

    IRetryAnalyzer retry = annotation.getRetryAnalyzer();
    if (retry == null) {
        annotation.setRetryAnalyzer(TestngRetry.class);
    }

    // 设置 默认循环次数
    ConfigUtil property = ConfigUtil.getInstance();
    int count = Integer.valueOf(property.getProperty("loopCount"));
    LogUtil.info("默认每个方法循环" + count + "次");
    annotation.setInvocationCount(count);

    // 设置 需要特殊处理方法的循环次数
    String excepLoopCount = property.getProperty("excepLoopCount");
    String[] excepCount = excepLoopCount.split(";");
    for (int i = 0; i < excepCount.length; i++) {
        String[] temp = excepCount[i].split(",");
        if (testMethod.getName().equals(temp[0])) {
            LogUtil.info("该方法循环" + temp[1] + "次");

            annotation.setInvocationCount(Integer.valueOf(temp[1]));
        }

    }

}
项目:ats-framework    文件:DependencyRemovalTransformer.java   
public void transform(
                       ITestAnnotation annotation,
                       Class testClass,
                       Constructor testConstructor,
                       Method testMethod ) {

    annotation.setDependsOnMethods(null);
    annotation.setDependsOnGroups(null);
}
项目:TestNG-Foundation    文件:ChainedListener.java   
@SuppressWarnings("rawtypes")
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testCtor,
                Method testMethod) {

    if (testClass != null) {
        xformTest.add("class: " + testClass.getSimpleName());
    } else if (testCtor != null) {
        xformTest.add("ctor: " + testCtor.getName());
    } else {
        xformTest.add("method: " + testMethod.getName());
    }
}
项目:oldmonk    文件:RetryListener.java   
@SuppressWarnings("rawtypes")
public void transform(final ITestAnnotation annotation, final Class testClass, final Constructor testConstructor,
        final Method testMethod)
{
    final IRetryAnalyzer retry = annotation.getRetryAnalyzer();
    if (retry == null)
    {
        annotation.setRetryAnalyzer(Retry.class);
    }
}
项目:qaf    文件:MethodHelper.java   
protected static boolean isEnabled(Method m, IAnnotationFinder finder) {
  ITestAnnotation annotation = AnnotationHelper.findTest(finder, m);

  // If no method annotation, look for one on the class
  if (null == annotation) {
    annotation = AnnotationHelper.findTest(finder, m.getDeclaringClass());
  }

  return isEnabled(annotation);
}
项目:wildfly-swarm    文件:TestNGAnnotationTransformer.java   
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {

    if (testMethod == null || annotation == null) {
        return;
    }

    String clazzName = testMethod.getDeclaringClass().getName();
    exclusions.forEach(s -> {
        if(s.equals(clazzName)) {
            annotation.setEnabled(false);
        }
    });

}
项目:webUIAuto    文件:RetryListener.java   
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
    IRetryAnalyzer retry = annotation.getRetryAnalyzer();
       if (retry == null) {
           annotation.setRetryAnalyzer(TestngRetry.class);
       }        
}
项目:seleniumtestsframework    文件:TestRetryListener.java   
public void transform(final ITestAnnotation annotation, final Class testClass, final Constructor testConstructor,
        final Method testMethod) {
    IRetryAnalyzer retryAnalyzer = annotation.getRetryAnalyzer();
    if (retryAnalyzer == null) {
        annotation.setRetryAnalyzer(TestRetryAnalyzer.class);
    }
}
项目:OptimusPrime    文件:AnnotationTransformer.java   
public void transform(ITestAnnotation annotation, Class testClass,
        Constructor testConstructor, Method testMethod) {
    IRetryAnalyzer analyzer = annotation.getRetryAnalyzer();

    if (analyzer == null) {
        annotation.setRetryAnalyzer(FailedTestsRetryListner.class);
    }

}
项目:AppiumTestDistribution    文件:RetryListener.java   
@Override
public void transform(ITestAnnotation iTestAnnotation,
                      Class aClass, Constructor constructor, Method method) {
    IRetryAnalyzer retry = iTestAnnotation.getRetryAnalyzer();

    if (retry == null) {
        iTestAnnotation.setRetryAnalyzer(Retry.class);
    }
}
项目:Prospero    文件:TestNGThreadPoolAnnotationTransformer.java   
@SuppressWarnings("rawtypes")
   public void transform(ITestAnnotation annotation, Class testClass,
    Constructor testConstructor, Method testMethod) {
if (performanceTestMethod != null
    && performanceTestMethod.equalsIgnoreCase(testMethod.getName())) {
    annotation.setThreadPoolSize(threadPoolSize);
    annotation.setInvocationCount(threadPoolSize);
}
   }
项目:selenium-test-automation-framework    文件:RetryListener.java   
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor constructor, Method method) {
  IRetryAnalyzer retry = annotation.getRetryAnalyzer();

  if(retry == null) {
    annotation.setRetryAnalyzer(RetryFailed.class);
  }
}
项目:buck    文件:TestNGRunner.java   
@Override
@SuppressWarnings("rawtypes")
public void transform(
    ITestAnnotation annotation,
    Class testClass,
    Constructor testConstructor,
    Method testMethod) {
  if (testMethod == null) {
    return;
  }
  String className = testMethod.getDeclaringClass().getName();
  String methodName = testMethod.getName();
  TestDescription description = new TestDescription(className, methodName);
  TestSelector matchingSelector = testSelectorList.findSelector(description);
  if (!matchingSelector.isInclusive()) {
    // For tests that have been filtered out, record it now and don't run it
    if (shouldExplainTestSelectors) {
      String reason = "Excluded by filter: " + matchingSelector.getExplanation();
      results.add(TestResult.forExcluded(className, methodName, reason));
    }
    annotation.setEnabled(false);
    return;
  }
  if (!annotation.getEnabled()) {
    // on a dry run, have to record it now -- since it doesn't run, listener can't do it
    results.add(TestResult.forDisabled(className, methodName));
    return;
  }
  if (isDryRun) {
    // on a dry run, record it now and don't run it
    results.add(TestResult.forDryRun(className, methodName));
    annotation.setEnabled(false);
    return;
  }
}
项目:carina    文件:AnnotationTransformer.java   
@SuppressWarnings("rawtypes")
@Override
public void transform(ITestAnnotation testAnnotation, Class clazz, Constructor test, Method method)
{
    IRetryAnalyzer retry = testAnnotation.getRetryAnalyzer();
    if (retry == null)
    {
        testAnnotation.setRetryAnalyzer(RetryAnalyzer.class);
    }
    LOGGER.debug("retry analyzer: " + method.getName() + testAnnotation.getRetryAnalyzer());
}
项目:qaf    文件:MethodHelper.java   
protected static boolean isEnabled(Class<?> objectClass, IAnnotationFinder finder) {
  ITestAnnotation testClassAnnotation = AnnotationHelper.findTest(finder, objectClass);
  return isEnabled(testClassAnnotation);
}
项目:codenvy    文件:OnpremSeleniumTestHandler.java   
@Override
public void transform(
    ITestAnnotation annotation,
    Class testClass,
    Constructor testConstructor,
    Method testMethod) {}
项目:tempto    文件:ProductTestAnnotationTransformer.java   
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod)
{
    ensureAnnotationIsOnlyOnTestMethod(testClass, testConstructor, testMethod);
}