Java 类org.testng.IReporter 实例源码

项目:wtf-core    文件:WTFTest.java   
public static void addReporterIfNotAddedBefore(Class<?> reporterClass)
        throws IllegalAccessException, InstantiationException {
    TestNG tng = com.beust.testng.TestNG.getDefault();
    for (IReporter reptr : tng.getReporters()) {
        if (reporterClass.isInstance(reptr)) {
            return;
        }
    }
    tng.getReporters().add((IReporter) reporterClass.newInstance());
}
项目:buck    文件:TestNGRunner.java   
@Override
public void run() throws Throwable {
  for (String className : testClassNames) {
    if (!shouldIncludeTest(className)) {
      continue;
    }

    final Class<?> testClass = Class.forName(className);

    List<TestResult> results;
    if (!mightBeATestClass(testClass)) {
      results = Collections.emptyList();
    } else {
      results = new ArrayList<>();
      TestNG testng = new TestNG();
      testng.setUseDefaultListeners(false);
      testng.setAnnotationTransformer(new FilteringAnnotationTransformer(results));
      testng.setTestClasses(new Class<?>[] {testClass});
      testng.addListener(new TestListener(results));
      // use default TestNG reporters ...
      testng.addListener(new SuiteHTMLReporter());
      testng.addListener((IReporter) new FailedReporter());
      testng.addListener(new XMLReporter());
      testng.addListener(new EmailableReporter());
      // ... except this replaces JUnitReportReporter ...
      testng.addListener(new JUnitReportReporterWithMethodParameters());
      // ... and we can't access TestNG verbosity, so we remove VerboseReporter
      testng.run();
    }

    writeResult(className, results);
  }
}