private List<Runner> runners(Class<?>[] children) { List<Runner> runners = new ArrayList<Runner>(); for (Class<?> each : children) { Runner childRunner = safeRunnerForClass(each); if (childRunner != null) { runners.add(childRunner); } } return runners; } }
/** * Called by this class and subclasses once the classes making up the suite have been determined * * @param builder builds runners for classes in the suite * @param klass the root of the suite * @param suiteClasses the classes in the suite */ protected Suite(RunnerBuilder builder, Class<?> klass, Class<?>[] suiteClasses) throws InitializationError { this(klass, builder.runners(klass, suiteClasses)); }
/** * Create a single-class runner for {@code testClass}, using {@code builder} */ protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable { return builder.runnerForClass(testClass); } }
/** * Constructs and returns a list of Runners, one for each child class in * {@code children}. Care is taken to avoid infinite recursion: * this builder will throw an exception if it is requested for another * runner for {@code parent} before this call completes. */ public List<Runner> runners(Class<?> parent, Class<?>[] children) throws InitializationError { addParent(parent); try { return runners(children); } finally { removeParent(parent); } }
/** * Always returns a runner for the given test class. * * <p>In case of an exception a runner will be returned that prints an error instead of running * tests. * * <p>Note that some of the internal JUnit implementations of RunnerBuilder will return * {@code null} from this method, but no RunnerBuilder passed to a Runner constructor will * return {@code null} from this method. * * @param testClass class to be run * @return a Runner */ public Runner safeRunnerForClass(Class<?> testClass) { try { Runner runner = runnerForClass(testClass); if (runner != null) { configureRunner(runner); } return runner; } catch (Throwable e) { return new ErrorReportingRunner(testClass, e); } }
/** * Constructs and returns a list of Runners, one for each child class in * {@code children}. Care is taken to avoid infinite recursion: * this builder will throw an exception if it is requested for another * runner for {@code parent} before this call completes. */ public List<Runner> runners(Class<?> parent, Class<?>[] children) throws InitializationError { addParent(parent); try { return runners(children); } finally { removeParent(parent); } }
private List<Runner> runners(Class<?>[] children) { ArrayList<Runner> runners = new ArrayList<Runner>(); for (Class<?> each : children) { Runner childRunner = safeRunnerForClass(each); if (childRunner != null) { runners.add(childRunner); } } return runners; } }
/** * Call this when there is no single root class (for example, multiple class names * passed on the command line to {@link org.junit.runner.JUnitCore} * * @param builder builds runners for classes in the suite * @param classes the classes in the suite */ public Suite(RunnerBuilder builder, Class<?>[] classes) throws InitializationError { this(null, builder.runners(null, classes)); }
/** * Constructs and returns a list of Runners, one for each child class in * {@code children}. Care is taken to avoid infinite recursion: * this builder will throw an exception if it is requested for another * runner for {@code parent} before this call completes. */ public List<Runner> runners(Class<?> parent, Class<?>[] children) throws InitializationError { addParent(parent); try { return runners(children); } finally { removeParent(parent); } }
/** * Create a single-class runner for {@code testClass}, using {@code builder} */ protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable { return builder.runnerForClass(testClass); } }
@Override public Runner runnerForClass(Class<?> testClass) throws Throwable { List<RunnerBuilder> builders = Arrays.asList( ignoredBuilder(), annotatedBuilder(), suiteMethodBuilder(), junit3Builder(), junit4Builder()); for (RunnerBuilder each : builders) { Runner runner = each.safeRunnerForClass(testClass); if (runner != null) { return runner; } } return null; }
/** * Call this when there is no single root class (for example, multiple class names * passed on the command line to {@link org.junit.runner.JUnitCore} * * @param builder builds runners for classes in the suite * @param classes the classes in the suite */ public Suite(RunnerBuilder builder, Class<?>[] classes) throws InitializationError { this(null, builder.runners(null, classes)); }
/** * Constructs and returns a list of Runners, one for each child class in * {@code children}. Care is taken to avoid infinite recursion: * this builder will throw an exception if it is requested for another * runner for {@code parent} before this call completes. */ public List<Runner> runners(Class<?> parent, Class<?>[] children) throws InitializationError { addParent(parent); try { return runners(children); } finally { removeParent(parent); } }
/** * Always returns a runner, even if it is just one that prints an error instead of running tests. * * @param testClass class to be run * @return a Runner */ public Runner safeRunnerForClass(Class<?> testClass) { try { return runnerForClass(testClass); } catch (Throwable e) { return new ErrorReportingRunner(testClass, e); } }
RunnerTestDescriptor createRunnerTestDescriptor(TestClassRequest request, UniqueId engineId) { Class<?> testClass = request.getTestClass(); Runner runner = RUNNER_BUILDER.safeRunnerForClass(testClass); if (runner == null) { return null; } return determineRunnerTestDescriptor(testClass, runner, request.getFilters(), engineId); }
/** * Called by this class and subclasses once the classes making up the suite have been determined * * @param builder builds runners for classes in the suite * @param klass the root of the suite * @param suiteClasses the classes in the suite */ protected Suite(RunnerBuilder builder, Class<?> klass, Class<?>[] suiteClasses) throws InitializationError { this(klass, builder.runners(klass, suiteClasses)); }
/** * Constructs and returns a list of Runners, one for each child class in * {@code children}. Care is taken to avoid infinite recursion: * this builder will throw an exception if it is requested for another * runner for {@code parent} before this call completes. */ public List<Runner> runners(Class<?> parent, Class<?>[] children) throws InitializationError { addParent(parent); try { return runners(children); } finally { removeParent(parent); } }
/** * Create a single-class runner for {@code testClass}, using {@code builder} */ protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable { return builder.runnerForClass(testClass); } }
@Override public Runner runnerForClass(Class<?> testClass) throws Throwable { List<RunnerBuilder> builders = Arrays.asList( ignoredBuilder(), annotatedBuilder(), suiteMethodBuilder(), junit3Builder(), junit4Builder()); for (RunnerBuilder each : builders) { Runner runner = each.safeRunnerForClass(testClass); if (runner != null) { return runner; } } return null; }
public List<Runner> runners(Class<?> parent, List<Class<?>> children) throws InitializationError { return runners(parent, children.toArray(new Class<?>[0])); }