Known Direct Subclasses
Categories |
From a given set of test classes, runs only the classes and methods that are
annotated with either the category given with the @IncludeCategory
annotation, or a subtype of that category. |
Enclosed |
If you put tests in inner classes, Ant, for example, won't find them. |
Parameterized |
The custom runner Parameterized implements parameterized tests. |
|
Class Overview
Using 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.
Summary
Nested Classes |
@interface |
Suite.SuiteClasses |
The SuiteClasses annotation specifies the classes to be run when a class
annotated with @RunWith(Suite.class) is run. |
Public Constructors |
|
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 Constructors |
|
Suite(Class<?> klass, Class[]<?> suiteClasses)
Call this when the default builder is good enough.
|
|
Suite(RunnerBuilder builder, Class<?> klass, Class[]<?> suiteClasses)
Called by this class and subclasses once the classes making up the suite have been determined
|
|
Suite(Class<?> klass, List<Runner> runners)
Called by this class and subclasses once the runners making up the suite have been determined
|
[Expand]
Inherited Methods |
From class
org.junit.runners.ParentRunner
Statement
|
childrenInvoker(RunNotifier notifier)
|
Statement
|
classBlock(RunNotifier notifier)
Constructs a Statement to run all of the tests in the test class.
|
void
|
collectInitializationErrors(List<Throwable> errors)
Adds to errors a throwable for each problem noted with the test class (available from getTestClass() ).
|
abstract
Description
|
describeChild(T child)
|
void
|
filter(Filter filter)
Remove tests that don't pass the parameter filter .
|
abstract
List<T>
|
getChildren()
Returns a list of objects that define the children of this Runner.
|
Description
|
getDescription()
|
String
|
getName()
Returns a name used to describe this Runner
|
final
TestClass
|
getTestClass()
Returns a TestClass object wrapping the class to be executed.
|
void
|
run(RunNotifier notifier)
Run the tests for this runner.
|
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 by getChildren() .
|
void
|
setScheduler(RunnerScheduler scheduler)
Sets a scheduler that determines the order and parallelization
of children.
|
void
|
sort(Sorter sorter)
Sorts the tests using sorter
|
void
|
validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors)
Adds to errors if any method in this class is annotated with
annotation , but:
- is not public, or
- takes parameters, or
- returns something other than void, or
- is static (given
isStatic is false ), or
- is not static (given
isStatic is true ).
|
Statement
|
withAfterClasses(Statement statement)
Returns a 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 .
|
Statement
|
withBeforeClasses(Statement statement)
Returns a 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.
|
|
From class
org.junit.runner.Runner
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
org.junit.runner.Describable
|
From interface
org.junit.runner.manipulation.Filterable
abstract
void
|
filter(Filter filter)
Remove tests that don't pass the parameter filter .
|
|
From interface
org.junit.runner.manipulation.Sortable
abstract
void
|
sort(Sorter sorter)
Sorts the tests using sorter
|
|
Public Constructors
Called reflectively on classes annotated with @RunWith(Suite.class)
Parameters
klass
| the root class |
builder
| builds runners for classes in the suite |
Call this when there is no single root class (for example, multiple class names
passed on the command line to JUnitCore
Parameters
builder
| builds runners for classes in the suite |
classes
| the classes in the suite |
Protected Constructors
protected
Suite
(Class<?> klass, Class[]<?> suiteClasses)
Call this when the default builder is good enough. Left in for compatibility with JUnit 4.4.
Parameters
klass
| the root of the suite |
suiteClasses
| the classes in the suite |
protected
Suite
(RunnerBuilder builder, Class<?> klass, Class[]<?> suiteClasses)
Called by this class and subclasses once the classes making up the suite have been determined
Parameters
builder
| builds runners for classes in the suite |
klass
| the root of the suite |
suiteClasses
| the classes in the suite |
protected
Suite
(Class<?> klass, List<Runner> runners)
Called by this class and subclasses once the runners making up the suite have been determined
Parameters
klass
| root of the suite |
runners
| for each class in the suite, a Runner |
Public Methods
public
static
Runner
emptySuite
()
Protected Methods
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 getChildren()
.
Subclasses are responsible for making sure that relevant test events are
reported through notifier