| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.junit.runner.Runner
org.junit.runners.ParentRunner<T>
public abstract class ParentRunner<T>
Provides most of the functionality specific to a Runner that implements a
 "parent node" in the test tree, with children defined by objects of some data
 type T. (For BlockJUnit4ClassRunner, T is
 Method . For Suite, T is Class.) Subclasses
 must implement finding the children of the node, describing each child, and
 running each child. ParentRunner will filter and sort children, handle
 @BeforeClass and @AfterClass methods,
 handle annotated ClassRules, create a composite
 Description, and run children sequentially.
| Constructor Summary | |
|---|---|
| protected  | ParentRunner(Class<?> testClass)Constructs a new ParentRunnerthat will run@TestClass | 
| Method Summary | |
|---|---|
| protected  Statement | childrenInvoker(RunNotifier notifier)Returns a Statement: CallrunChild(Object, RunNotifier)on each object returned bygetChildren()(subject to any imposed
 filter and sort) | 
| protected  Statement | classBlock(RunNotifier notifier)Constructs a Statementto run all of the tests in the test class. | 
| protected  List<TestRule> | classRules() | 
| protected  void | collectInitializationErrors(List<Throwable> errors)Adds to errorsa throwable for each problem noted with the test class (available fromgetTestClass()). | 
| protected  TestClass | createTestClass(Class<?> testClass) | 
| protected abstract  Description | describeChild(T child)Returns a Descriptionforchild, which can be assumed to
 be an element of the list returned bygetChildren() | 
|  void | filter(Filter filter)Remove tests that don't pass the parameter filter. | 
| protected abstract  List<T> | getChildren()Returns a list of objects that define the children of this Runner. | 
|  Description | getDescription() | 
| protected  String | getName()Returns a name used to describe this Runner | 
| protected  Annotation[] | getRunnerAnnotations() | 
|  TestClass | getTestClass()Returns a TestClassobject wrapping the class to be executed. | 
| protected  boolean | isIgnored(T child)Evaluates whether a child is ignored. | 
|  void | run(RunNotifier notifier)Run the tests for this runner. | 
| protected abstract  void | runChild(T child,
                 RunNotifier notifier)Runs the test corresponding to child, which can be assumed to be
 an element of the list returned bygetChildren(). | 
| protected  void | runLeaf(Statement statement,
               Description description,
               RunNotifier notifier)Runs a Statementthat represents a leaf (aka atomic) test. | 
|  void | setScheduler(RunnerScheduler scheduler)Sets a scheduler that determines the order and parallelization of children. | 
|  void | sort(Sorter sorter)Sorts the tests using sorter | 
| protected  void | validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation,
                                                             boolean isStatic,
                                                             List<Throwable> errors)Adds to errorsif any method in this class is annotated withannotation, but:
 
 is not public, or
 takes parameters, or
 returns something other than void, or
 is static (givenisStatic is false), or
 is not static (givenisStatic is true). | 
| protected  Statement | withAfterClasses(Statement statement)Returns a Statement: run all non-overridden@AfterClassmethods on this class
 and superclasses before executingstatement; all AfterClass methods are
 always executed: exceptions thrown by previous steps are combined, if
 necessary, with exceptions from AfterClass methods into aMultipleFailureException. | 
| protected  Statement | withBeforeClasses(Statement statement)Returns a Statement: run all non-overridden@BeforeClassmethods on this class
 and superclasses before executingstatement; if any throws an
 Exception, stop execution and pass the exception on. | 
| Methods inherited from class org.junit.runner.Runner | 
|---|
| testCount | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
protected ParentRunner(Class<?> testClass)
                throws InitializationError
ParentRunner that will run @TestClass
InitializationError| Method Detail | 
|---|
protected TestClass createTestClass(Class<?> testClass)
protected abstract List<T> getChildren()
protected abstract Description describeChild(T child)
Description for child, which can be assumed to
 be an element of the list returned by getChildren()
protected abstract void runChild(T child,
                                 RunNotifier notifier)
child, which can be assumed to be
 an element of the list returned by getChildren().
 Subclasses are responsible for making sure that relevant test events are
 reported through notifier
protected void collectInitializationErrors(List<Throwable> errors)
errors a throwable for each problem noted with the test class (available from getTestClass()).
 Default implementation adds an error for each method annotated with
 @BeforeClass or @AfterClass that is not
 public static void with no arguments.
protected void validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation,
                                              boolean isStatic,
                                              List<Throwable> errors)
errors if any method in this class is annotated with
 annotation, but:
 isStatic is false), or
 isStatic is true).
 
protected Statement classBlock(RunNotifier notifier)
Statement to run all of the tests in the test class.
 Override to add pre-/post-processing. Here is an outline of the
 implementation:
 getChildren()
 (subject to any imposed filter and sort).ClassRules on the test-class and superclasses.@BeforeClass methods on the test-class
 and superclasses; if any throws an Exception, stop execution and pass the
 exception on.@AfterClass methods on the test-class
 and superclasses: exceptions thrown by previous steps are combined, if
 necessary, with exceptions from AfterClass methods into a
 MultipleFailureException.
Statementprotected Statement withBeforeClasses(Statement statement)
Statement: run all non-overridden @BeforeClass methods on this class
 and superclasses before executing statement; if any throws an
 Exception, stop execution and pass the exception on.
protected Statement withAfterClasses(Statement statement)
Statement: run all non-overridden @AfterClass methods on this class
 and superclasses before executing statement; all AfterClass methods are
 always executed: exceptions thrown by previous steps are combined, if
 necessary, with exceptions from AfterClass methods into a
 MultipleFailureException.
protected List<TestRule> classRules()
ClassRules that can transform the block that runs
         each method in the tested class.protected Statement childrenInvoker(RunNotifier notifier)
Statement: Call runChild(Object, RunNotifier)
 on each object returned by getChildren() (subject to any imposed
 filter and sort)
protected boolean isIgnored(T child)
false.
 
 BlockJUnit4ClassRunner, for example, overrides this method to
 filter tests based on the Ignore annotation.
protected String getName()
public final TestClass getTestClass()
TestClass object wrapping the class to be executed.
protected final void runLeaf(Statement statement,
                             Description description,
                             RunNotifier notifier)
Statement that represents a leaf (aka atomic) test.
protected Annotation[] getRunnerAnnotations()
public Description getDescription()
getDescription in interface DescribablegetDescription in class RunnerDescription showing the tests to be run by the receiverpublic void run(RunNotifier notifier)
Runner
run in class Runnernotifier - will be notified of events while tests are being run--tests being
 started, finishing, and failing
public void filter(Filter filter)
            throws NoTestsRemainException
Filterablefilter.
filter in interface Filterablefilter - the Filter to apply
NoTestsRemainException - if all tests are filtered outpublic void sort(Sorter sorter)
Sortablesorter
sort in interface Sortablesorter - the Sorter to use for sorting the testspublic void setScheduler(RunnerScheduler scheduler)
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||