java.lang.Object | |||
↳ | org.junit.runner.Runner | ||
↳ | org.junit.runners.ParentRunner<T> | ||
↳ | org.junit.runners.BlockJUnit4ClassRunner |
Known Direct Subclasses |
Implements the JUnit 4 standard test case class model, as defined by the
annotations in the org.junit package. Many users will never notice this
class: it is now the default test class runner, but it should have exactly
the same behavior as the old test class runner (JUnit4ClassRunner
).
BlockJUnit4ClassRunner has advantages for writers of custom JUnit runners
that are slight changes to the default behavior, however:
Statement
s,
allowing new operations to be inserted into the appropriate point in the
execution flow.
JUnit4ClassRunner
was in an internal package, and is now deprecated.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a BlockJUnit4ClassRunner to run
klass |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds to
errors a throwable for each problem noted with the test class (available from getTestClass() ). | |||||||||||
Returns the methods that run tests.
| |||||||||||
Returns a new fixture for running a test.
| |||||||||||
Returns a
Description for child , which can be assumed to
be an element of the list returned by getChildren()
| |||||||||||
Returns a list of objects that define the children of this Runner.
| |||||||||||
Returns a Statement that, when executed, either returns normally if
method passes, or throws an exception if method fails. | |||||||||||
This method is deprecated.
Will be private soon: use Rules instead
| |||||||||||
Runs the test corresponding to
child , which can be assumed to be
an element of the list returned by getChildren() . | |||||||||||
Returns the name that describes
method for Description s. | |||||||||||
Adds to
errors if the test class has more than one constructor,
or if the constructor takes parameters. | |||||||||||
This method is deprecated.
unused API, will go away in future version
| |||||||||||
Adds to
errors if the test class has more than one constructor
(do not override)
| |||||||||||
Adds to
errors for each method annotated with @Test that
is not a public, void instance method with no arguments. | |||||||||||
Adds to
errors if the test class's single constructor takes
parameters (do not override)
| |||||||||||
This method is deprecated.
Will be private soon: use Rules instead
| |||||||||||
This method is deprecated.
Will be private soon: use Rules instead
| |||||||||||
This method is deprecated.
Will be private soon: use Rules instead
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.junit.runners.ParentRunner
| |||||||||||
From class
org.junit.runner.Runner
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.junit.runner.Describable
| |||||||||||
From interface
org.junit.runner.manipulation.Filterable
| |||||||||||
From interface
org.junit.runner.manipulation.Sortable
|
Creates a BlockJUnit4ClassRunner to run klass
InitializationError | if the test class is malformed. |
---|
Adds to 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.
Returns the methods that run tests. Default implementation returns all
methods annotated with @Test
on this class and superclasses that
are not overridden.
Returns a new fixture for running a test. Default implementation executes the test class's no-argument constructor (validation should have ensured one exists).
Exception |
---|
Returns a Description
for child
, which can be assumed to
be an element of the list returned by getChildren()
Returns a list of objects that define the children of this Runner.
Returns a Statement that, when executed, either returns normally if
method
passes, or throws an exception if method
fails.
Here is an outline of the default implementation:
method
on the result of createTest()
, and
throw any exceptions thrown by either operation.
method
's @Test
annotation has the expecting
attribute, return normally only if the previous step threw an
exception of the correct type, and throw an exception otherwise.
method
's @Test
annotation has the timeout
attribute, throw an exception if the previous step takes more
than the specified number of milliseconds.
@Rule
fields to modify the execution of the
above steps. A Rule
may prevent all execution of the above steps,
or add additional behavior before and after, or modify thrown exceptions.
For more information, see MethodRule
@Before
methods on this class
and superclasses before any of the previous steps; if any throws an
Exception, stop execution and pass the exception on.
@After
methods on this class
and superclasses after any of the previous steps; all After methods are
always executed: exceptions thrown by previous steps are combined, if
necessary, with exceptions from After methods into a
MultipleFailureException
.
Returns a Statement
that invokes method
on test
This method is deprecated.
Will be private soon: use Rules instead
Returns a Statement
: if method
's @Test
annotation
has the expecting
attribute, return normally only if next
throws an exception of the correct type, and throw an exception
otherwise.
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
Returns the name that describes method
for Description
s.
Default implementation is the method's name
Adds to errors
if the test class has more than one constructor,
or if the constructor takes parameters. Override if a subclass requires
different validation rules.
This method is deprecated.
unused API, will go away in future version
Adds to errors
for each method annotated with @Test
,
@Before
, or @After
that is not a public, void instance
method with no arguments.
Adds to errors
if the test class has more than one constructor
(do not override)
Adds to errors
for each method annotated with @Test
that
is not a public, void instance method with no arguments.
Adds to errors
if the test class's single constructor takes
parameters (do not override)
This method is deprecated.
Will be private soon: use Rules instead
Returns a Statement
: run all non-overridden @After
methods on this class and superclasses before running next
; all
After methods are always executed: exceptions thrown by previous steps
are combined, if necessary, with exceptions from After methods into a
MultipleFailureException
.
This method is deprecated.
Will be private soon: use Rules instead
Returns a Statement
: run all non-overridden @Before
methods on this class and superclasses before running next
; if
any throws an Exception, stop execution and pass the exception on.
This method is deprecated.
Will be private soon: use Rules instead
Returns a Statement
: if method
's @Test
annotation
has the timeout
attribute, throw an exception if next
takes more than the specified number of milliseconds.