|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.junit.runner.notification.RunListener
public class RunListener
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); }
JUnitCore
Constructor Summary | |
---|---|
RunListener()
|
Method Summary | |
---|---|
void |
testFailure(Failure failure)
Called when an atomic test fails. |
void |
testFinished(Description description)
Called when an atomic test has finished, whether the test succeeds or fails. |
void |
testIgnored(Description description)
Called when a test will not be run, generally because a test method is annotated with Ignore . |
void |
testRunFinished(Result result)
Called when all tests have finished |
void |
testRunStarted(Description description)
Called before any tests have been run. |
void |
testStarted(Description description)
Called when an atomic test is about to be started. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RunListener()
Method Detail |
---|
public void testRunStarted(Description description) throws java.lang.Exception
description
- describes the tests to be run
java.lang.Exception
public void testRunFinished(Result result) throws java.lang.Exception
result
- the summary of the test run, including all the tests that failed
java.lang.Exception
public void testStarted(Description description) throws java.lang.Exception
description
- the description of the test that is about to be run
(generally a class and method name)
java.lang.Exception
public void testFinished(Description description) throws java.lang.Exception
description
- the description of the test that just ran
java.lang.Exception
public void testFailure(Failure failure) throws java.lang.Exception
failure
- describes the test that failed and the exception that was thrown
java.lang.Exception
public void testIgnored(Description description) throws java.lang.Exception
Ignore
.
description
- describes the test that will not be run
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |