// TODO: require an instance? @Override public void run(RunNotifier notifier) { List<Class<?>> allPossibleClasses = gatherClasses(); List<Runner> allPossibleRunners = runnersForClasses(allPossibleClasses); List<Runner> valid = filterRunners(allPossibleRunners); for (Runner each : valid) each.run(notifier); }
@Override protected void runChild(Runner child, RunNotifier notifier) { if (!(initialized)) { initialize(); } child.run(notifier); }
private Description getRootDescription(Runner runner, DescriptionMatcher matcher) { Description current = runner.getDescription(); while (true) { List<Description> children = current.getChildren(); if (children.size() != 1 || matcher.matches(current)) return current; current = children.get(0); } }
// TODO: this type correct? @Override public List<Runner> matchingRunners(List<? extends Runner> allPossibleRunners) { ArrayList<Runner> result = new ArrayList<Runner>(); for (Runner eachRunner : allPossibleRunners) { Collection<Annotation> annotations = eachRunner.getDescription().getAnnotations(); // TODO: extract method for (Annotation eachAnnotation : annotations) { if (eachAnnotation.annotationType().equals(Category.class)) { Category category = (Category) eachAnnotation; Class<?>[] categories = category.value(); if (Arrays.asList(categories).contains(fIncluded)) result.add(eachRunner); } } } // TODO Auto-generated method stub return result; }
@Override public void run(RunNotifier notifier) { if (myTests == null) { runFailure( createTestDescription(ModuleSymbolicSuite.NO_TESTS), new IllegalStateException("no tests found in " + myClassName), notifier); } else if (myDelegate == null) { for (String test : myTests) { runFailure( createTestDescription(test), new ClassNotFoundException(myClassName), notifier); } } else { myDelegate.run(notifier); } }
@Override public void run(RunNotifier notifier) { cargoRunner.run(notifier); }
@Override public Description getDescription() { return cargoRunner.getDescription(); }
private ITestReference createUnfilteredTest(Class<?> clazz, String[] failureNames) { Request request = sortByFailures(Request.aClass(clazz), failureNames); Runner runner = request.getRunner(); Description description = runner.getDescription(); return new JUnit4TestReference(runner, description); }
@Override protected void runChild(Runner runner, final RunNotifier notifier) { runner.run(notifier); }
@Override protected Description describeChild(Runner child) { return child.getDescription(); }
@Test public void plansNamedCorrectly() throws Exception { Runner runner = Request.aClass(FibonacciTest.class).getRunner(); Description description = runner.getDescription(); assertEquals("[0]", description.getChildren().get(0).getDisplayName()); }
@Test public void countBeforeRun() throws Exception { Runner runner = Request.aClass(FibonacciTest.class).getRunner(); assertEquals(7, runner.testCount()); }