org.junit.internal.runners.ErrorReportingRunner源码实例Demo

类org.junit.internal.runners.ErrorReportingRunner源码实例Demo

下面列出了org.junit.internal.runners.ErrorReportingRunner 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pitest   文件: ParameterisedJUnitTestFinder.java
@Override
public List<TestUnit> findTestUnits(final Class<?> clazz) {

  final Runner runner = AdaptedJUnitTestUnit.createRunner(clazz);
  if ((runner == null)
      || runner.getClass().isAssignableFrom(ErrorReportingRunner.class)) {
    return Collections.emptyList();
  }

  if (isParameterizedTest(runner)) {
    return handleParameterizedTest(clazz, runner.getDescription());
  }

  return Collections.emptyList();

}
 
源代码2 项目: android-test   文件: AndroidLogOnlyBuilderTest.java
@Test
public void builderHandlesNotATest() throws Throwable {
  Runner selectedRunner = androidLogOnlyBuilder.runnerForClass(NotATest.class);
  if (scanningPath) {
    assertThat(selectedRunner, nullValue());
  } else {
    assertThat(selectedRunner, notNullValue());
    assertThat(selectedRunner.getClass(), typeCompatibleWith(ErrorReportingRunner.class));
    runWithRunner(selectedRunner, 1, 1);
  }
}
 
源代码3 项目: pitest   文件: AdaptedJUnitTestUnit.java
private void checkForErrorRunner(final Runner runner) {
  if (runner instanceof ErrorReportingRunner) {
    LOG.warning("JUnit error for class " + this.clazz + " : "
        + runner.getDescription());
  }

}
 
源代码4 项目: pitest   文件: JUnitCustomRunnerTestUnitFinder.java
private boolean isNotARunnableTest(final Runner runner,
    final String className) {
  try {
    return (runner == null)
        || runner.getClass().isAssignableFrom(ErrorReportingRunner.class)
        || isParameterizedTest(runner)
        || isAJUnitThreeErrorOrWarning(runner)
        || isJUnitThreeSuiteMethodNotForOwnClass(runner, className);
  } catch (final RuntimeException ex) {
    // some runners (looking at you spock) can throw a runtime exception
    // when the getDescription method is called
    return true;
  }
}
 
源代码5 项目: android-test   文件: AndroidLogOnlyBuilder.java
@Override
public Runner runnerForClass(Class<?> testClass) throws Throwable {
  // Increment the number of runners created.
  ++runnerCount;

  // Build non executing runners for JUnit3 test classes
  if (isJUnit3Test(testClass)) {
    // If scanning the path then make sure that it has at least one test method before
    // trying to run it.
    if (scanningPath && !hasJUnit3TestMethod(testClass)) {
      return null;
    }

    return new JUnit38ClassRunner(new NonExecutingTestSuite(testClass));
  } else if (hasSuiteMethod(testClass)) {
    if (runnerParams.isIgnoreSuiteMethods()) {
      return null;
    }

    Test test = SuiteMethod.testFromSuiteMethod(testClass);
    if (!(test instanceof TestSuite)) {
      // this should not be possible
      throw new IllegalArgumentException(
          testClass.getName() + "#suite() did not return a TestSuite");
    }
    return new JUnit38ClassRunner(new NonExecutingTestSuite((TestSuite) test));
  } else {
    // Reset the count of the number of Runners created for the supplied testClass. Save
    // away the number created for the parent testClass.
    int oldRunnerCount = runnerCount;
    Runner runner = builder.runnerForClass(testClass);
    if (null == runner) {
      // If the runner could not be created then do not wrap it.
      return null;
    } else if (runner instanceof ErrorReportingRunner) {
      // Preserve behavior where a failure during construction results in an error,
      // even while in logOnly mode, by simply returning the runner rather than
      // wrapping it.
      return runner;
    } else if (runnerCount > oldRunnerCount) {
      // If constructing the testClass caused us to reenter here to build Runner
      // instances, e.g. for Suite or Enclosed, then this must not wrap runner in a
      // NonExecutingRunner as that would cause problems if any of the nested classes
      // were JUnit 3 ones.
      return runner;
    } else {
      return new NonExecutingRunner(runner);
    }
  }
}
 
源代码6 项目: android-test   文件: TestLoaderTest.java
@Test
public void testLoadTests_runWith() {
  // This fails because it has no @Test annotated methods.
  assertLoadTestSuccess(JUnit4RunTest.class, ErrorReportingRunner.class);
}
 
源代码7 项目: android-test   文件: TestLoaderTest.java
@Test
public void testLoadTests_all() {
  Collection<String> classNames =
      Arrays.asList(
          JUnit3Test.class.getName(),
          EmptyJUnit3Test.class.getName(),
          JUnit4Test.class.getName(),
          JUnit4RunTest.class.getName(),
          NotATest.class.getName(),
          CustomTest.class.getName(),
          "notexist",
          AbstractTest.class.getName(),
          SubClassJUnit4Test.class.getName(),
          SubClassAbstractTest.class.getName());

  List<Runner> runners = loader.getRunnersFor(classNames, false);
  List<Class<? extends Runner>> runnerClasses = new ArrayList<>();
  for (Runner runner : runners) {
    runnerClasses.add(runner == null ? null : runner.getClass());
  }

  List<Class<? extends Runner>> expectedRunnerClasses;
  if (scanningPath) {
    // When scanning path TestLoader is stricter about what it will accept as a test.
    expectedRunnerClasses =
        Arrays.asList(
            JUnit38ClassRunner.class,
            AndroidJUnit4ClassRunner.class,
            ErrorReportingRunner.class,
            UnloadableClassRunner.class,
            AndroidJUnit4ClassRunner.class,
            JUnit38ClassRunner.class);
  } else {
    expectedRunnerClasses =
        Arrays.asList(
            JUnit38ClassRunner.class,
            JUnit38ClassRunner.class,
            AndroidJUnit4ClassRunner.class,
            ErrorReportingRunner.class,
            ErrorReportingRunner.class,
            ErrorReportingRunner.class,
            UnloadableClassRunner.class,
            JUnit38ClassRunner.class,
            AndroidJUnit4ClassRunner.class,
            JUnit38ClassRunner.class);
  }
  assertEquals(expectedRunnerClasses, runnerClasses);
}
 
源代码8 项目: android-test   文件: TestLoaderTest.java
@Test
public void testLoadTests_notATest() {
  assertScanningLoadsAnyClass(NotATest.class, ErrorReportingRunner.class);
}
 
源代码9 项目: android-test   文件: TestLoaderTest.java
@Test
public void testLoadTests_CustomTest() {
  assertScanningLoadsAnyClass(CustomTest.class, ErrorReportingRunner.class);
}
 
源代码10 项目: bazel   文件: JUnit4Runner.java
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
private static Request createErrorReportingRequestForFilterError(Filter filter) {
  ErrorReportingRunner runner = new ErrorReportingRunner(Filter.class, new Exception(
      String.format("No tests found matching %s", filter.describe())));
  return Request.runner(runner);
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法