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

下面列出了怎么用org.junit.internal.runners.SuiteMethod的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android-test   文件: AndroidSuiteBuilder.java
@Override
public Runner runnerForClass(Class<?> testClass) throws Throwable {
  if (androidRunnerParams.isIgnoreSuiteMethods()) {
    return null;
  }
  try {
    if (hasSuiteMethod(testClass)) {
      Test t = SuiteMethod.testFromSuiteMethod(testClass);
      if (!(t instanceof TestSuite)) {
        // this should not be possible
        throw new IllegalArgumentException(
            testClass.getName() + "#suite() did not return a TestSuite");
      }
      return new JUnit38ClassRunner(new AndroidTestSuite((TestSuite) t, androidRunnerParams));
    }
  } catch (Throwable e) {
    // log error message including stack trace before throwing to help with debugging.
    Log.e(LOG_TAG, "Error constructing runner", e);
    throw e;
  }
  return null;
}
 
源代码2 项目: beanshell   文件: AllTestsJUnit4Runner.java
public AllTestsJUnit4Runner(Class<?> klass) throws InitializationError {
    super(klass);
    try {
        suite = (TestSuite) SuiteMethod.testFromSuiteMethod(klass);
        method = TestCase.class.getDeclaredMethod("runBare");
    } catch (Throwable t) { throw new InitializationError(t); }

}
 
源代码3 项目: 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);
    }
  }
}
 
源代码4 项目: pitest   文件: RunnerSuiteFinder.java
private static Predicate<Description> isSuiteMethodRunner(final Runner runner) {
  return a -> SuiteMethod.class.isAssignableFrom(runner.getClass());
}
 
 类所在包
 同包方法