public class Suite extends ParentRunner<Runner>
Suite
as a runner allows you to manually
build a suite containing tests from many classes. It is the JUnit 4 equivalent of the JUnit 3.8.x
static Test
suite()
method. To use it, annotate a class
with @RunWith(Suite.class)
and @SuiteClasses({TestClass1.class, ...})
.
When you run this class, it will run all the tests in all the suite classes.Modifier and Type | Class and Description |
---|---|
static interface |
Suite.SuiteClasses
The
SuiteClasses annotation specifies the classes to be run when a class
annotated with @RunWith(Suite.class) is run. |
Modifier | Constructor and Description |
---|---|
protected |
Suite(Class<?> klass,
Class<?>[] suiteClasses)
Call this when the default builder is good enough.
|
protected |
Suite(Class<?> klass,
List<Runner> runners)
Called by this class and subclasses once the runners making up the suite have been determined
|
|
Suite(Class<?> klass,
RunnerBuilder builder)
Called reflectively on classes annotated with
@RunWith(Suite.class) |
|
Suite(RunnerBuilder builder,
Class<?>[] classes)
Call this when there is no single root class (for example, multiple class names
passed on the command line to
JUnitCore |
protected |
Suite(RunnerBuilder builder,
Class<?> klass,
Class<?>[] suiteClasses)
Called by this class and subclasses once the classes making up the suite have been determined
|
Modifier and Type | Method and Description |
---|---|
protected Description |
describeChild(Runner child)
Returns a
Description for child , which can be assumed to
be an element of the list returned by ParentRunner.getChildren() |
static Runner |
emptySuite()
Returns an empty suite.
|
protected List<Runner> |
getChildren()
Returns a list of objects that define the children of this Runner.
|
protected void |
runChild(Runner runner,
RunNotifier notifier)
Runs the test corresponding to
child , which can be assumed to be
an element of the list returned by ParentRunner.getChildren() . |
childrenInvoker, classBlock, classRules, collectInitializationErrors, filter, getDescription, getName, getRunnerAnnotations, getTestClass, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses
public Suite(Class<?> klass, RunnerBuilder builder) throws InitializationError
@RunWith(Suite.class)
klass
- the root classbuilder
- builds runners for classes in the suiteInitializationError
public Suite(RunnerBuilder builder, Class<?>[] classes) throws InitializationError
JUnitCore
builder
- builds runners for classes in the suiteclasses
- the classes in the suiteInitializationError
protected Suite(Class<?> klass, Class<?>[] suiteClasses) throws InitializationError
klass
- the root of the suitesuiteClasses
- the classes in the suiteInitializationError
protected Suite(RunnerBuilder builder, Class<?> klass, Class<?>[] suiteClasses) throws InitializationError
builder
- builds runners for classes in the suiteklass
- the root of the suitesuiteClasses
- the classes in the suiteInitializationError
protected Suite(Class<?> klass, List<Runner> runners) throws InitializationError
klass
- root of the suiterunners
- for each class in the suite, a Runner
InitializationError
public static Runner emptySuite()
protected List<Runner> getChildren()
ParentRunner
getChildren
in class ParentRunner<Runner>
protected Description describeChild(Runner child)
ParentRunner
Description
for child
, which can be assumed to
be an element of the list returned by ParentRunner.getChildren()
describeChild
in class ParentRunner<Runner>
protected void runChild(Runner runner, RunNotifier notifier)
ParentRunner
child
, which can be assumed to be
an element of the list returned by ParentRunner.getChildren()
.
Subclasses are responsible for making sure that relevant test events are
reported through notifier
runChild
in class ParentRunner<Runner>