Class Overview
If you put tests in inner classes, Ant, for example, won't find them. By running the outer class
with Enclosed, the tests in the inner classes will be run. You might put tests in inner classes
to group them for convenience or to share constants.
So, for example:
\@RunWith(Enclosed.class)
public class ListTests {
...useful shared stuff...
public static class OneKindOfListTest {...}
public static class AnotherKind {...}
}
For a real example, @see org.junit.tests.manipulation.SortableTest.
Summary
[Expand]
Inherited Methods |
From class
org.junit.runners.Suite
|
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
public
Enclosed
(Class<?> klass, RunnerBuilder builder)
Only called reflectively. Do not use programmatically.