Package org.junit.runner.notification
Class RunNotifier
java.lang.Object
org.junit.runner.notification.RunNotifier
If you write custom runners, you may need to notify JUnit of your progress running tests.
Do this by invoking the
RunNotifier passed to your implementation of
Runner.run(RunNotifier). Future evolution of this class is likely to
move fireTestRunStarted(Description) and fireTestRunFinished(Result)
to a separate class since they should only be called once per run.- Since:
- 4.0
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFirstListener(RunListener listener) Internal use only.voidaddListener(RunListener listener) Internal use onlyvoidfireTestAssumptionFailed(Failure failure) Invoke to tell listeners that an atomic test flagged that it assumed something false.voidfireTestFailure(Failure failure) Invoke to tell listeners that an atomic test failed.private voidfireTestFailures(List<RunListener> listeners, List<Failure> failures) voidfireTestFinished(Description description) Invoke to tell listeners that an atomic test finished.voidfireTestIgnored(Description description) Invoke to tell listeners that an atomic test was ignored.voidfireTestRunFinished(Result result) Do not invoke.voidfireTestRunStarted(Description description) Do not invoke.voidfireTestStarted(Description description) Invoke to tell listeners that an atomic test is about to start.voidfireTestSuiteFinished(Description description) Invoke to tell listeners that a test suite is about to finish.voidfireTestSuiteStarted(Description description) Invoke to tell listeners that a test suite is about to start.voidAsk that the tests run stop before starting the next test.voidremoveListener(RunListener listener) Internal use only(package private) RunListenerwrapIfNotThreadSafe(RunListener listener) Wraps the given listener withSynchronizedRunListenerif it is not annotated withRunListener.ThreadSafe.
-
Field Details
-
listeners
-
pleaseStop
private volatile boolean pleaseStop
-
-
Constructor Details
-
RunNotifier
public RunNotifier()
-
-
Method Details
-
addListener
Internal use only -
removeListener
Internal use only -
wrapIfNotThreadSafe
Wraps the given listener withSynchronizedRunListenerif it is not annotated withRunListener.ThreadSafe. -
fireTestRunStarted
Do not invoke. -
fireTestRunFinished
Do not invoke. -
fireTestSuiteStarted
Invoke to tell listeners that a test suite is about to start. Runners are strongly encouraged--but not required--to call this method. If this method is called for a givenDescriptionthenfireTestSuiteFinished(Description)MUST be called for the sameDescription.- Parameters:
description- the description of the suite test (generally a class name)- Since:
- 4.13
-
fireTestSuiteFinished
Invoke to tell listeners that a test suite is about to finish. Always invoke this method if you invokefireTestSuiteStarted(Description)as listeners are likely to expect them to come in pairs.- Parameters:
description- the description of the suite test (generally a class name)- Since:
- 4.13
-
fireTestStarted
Invoke to tell listeners that an atomic test is about to start.- Parameters:
description- the description of the atomic test (generally a class and method name)- Throws:
StoppedByUserException- thrown if a user has requested that the test run stop
-
fireTestFailure
Invoke to tell listeners that an atomic test failed.- Parameters:
failure- the description of the test that failed and the exception thrown
-
fireTestFailures
-
fireTestAssumptionFailed
Invoke to tell listeners that an atomic test flagged that it assumed something false.- Parameters:
failure- the description of the test that failed and theAssumptionViolatedExceptionthrown
-
fireTestIgnored
Invoke to tell listeners that an atomic test was ignored.- Parameters:
description- the description of the ignored test
-
fireTestFinished
Invoke to tell listeners that an atomic test finished. Always invoke this method if you invokefireTestStarted(Description)as listeners are likely to expect them to come in pairs.- Parameters:
description- the description of the test that finished
-
pleaseStop
public void pleaseStop()Ask that the tests run stop before starting the next test. Phrased politely because the test currently running will not be interrupted. It seems a little odd to put this functionality here, but theRunNotifieris the only object guaranteed to be shared amongst the many runners involved. -
addFirstListener
Internal use only. The Result's listener must be first.
-