java.lang.Object | |
↳ | org.junit.runner.notification.RunListener |
Known Direct Subclasses |
If you need to respond to the events during a test run, extend RunListener
and override the appropriate methods. If a listener throws an exception while processing a
test event, it will be removed for the remainder of the test run.
For example, suppose you have a Cowbell
class that you want to make a noise whenever a test fails. You could write:
public class RingingListener extends RunListener { public void testFailure(Failure failure) { Cowbell.ring(); } }
To invoke your listener, you need to run your tests through JUnitCore
.
public void main(String... args) { JUnitCore core= new JUnitCore(); core.addListener(new RingingListener()); core.run(MyTestClass.class); }
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Called when an atomic test flags that it assumes a condition that is
false
| |||||||||||
Called when an atomic test fails.
| |||||||||||
Called when an atomic test has finished, whether the test succeeds or fails.
| |||||||||||
Called when a test will not be run, generally because a test method is annotated
with
Ignore . | |||||||||||
Called when all tests have finished
| |||||||||||
Called before any tests have been run.
| |||||||||||
Called when an atomic test is about to be started.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Called when an atomic test flags that it assumes a condition that is false
failure | describes the test that failed and the
AssumptionViolatedException that was thrown
|
---|
Called when an atomic test fails.
failure | describes the test that failed and the exception that was thrown |
---|
Exception |
---|
Called when an atomic test has finished, whether the test succeeds or fails.
description | the description of the test that just ran |
---|
Exception |
---|
Called when all tests have finished
result | the summary of the test run, including all the tests that failed |
---|
Exception |
---|
Called before any tests have been run.
description | describes the tests to be run |
---|
Exception |
---|
Called when an atomic test is about to be started.
description | the description of the test that is about to be run (generally a class and method name) |
---|
Exception |
---|