public class RunNotifier
extends java.lang.Object
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.Modifier and Type | Class and Description |
---|---|
private class |
RunNotifier.SafeNotifier |
Modifier and Type | Field and Description |
---|---|
private java.util.List<RunListener> |
listeners |
private boolean |
pleaseStop |
Constructor and Description |
---|
RunNotifier() |
Modifier and Type | Method and Description |
---|---|
void |
addFirstListener(RunListener listener)
Internal use only.
|
void |
addListener(RunListener listener)
Internal use only
|
void |
fireTestAssumptionFailed(Failure failure)
Invoke to tell listeners that an atomic test flagged that it assumed
something false.
|
void |
fireTestFailure(Failure failure)
Invoke to tell listeners that an atomic test failed.
|
private void |
fireTestFailures(java.util.List<RunListener> listeners,
java.util.List<Failure> failures) |
void |
fireTestFinished(Description description)
Invoke to tell listeners that an atomic test finished.
|
void |
fireTestIgnored(Description description)
Invoke to tell listeners that an atomic test was ignored.
|
void |
fireTestRunFinished(Result result)
Do not invoke.
|
void |
fireTestRunStarted(Description description)
Do not invoke.
|
void |
fireTestStarted(Description description)
Invoke to tell listeners that an atomic test is about to start.
|
void |
fireTestSuiteFinished(Description description)
Invoke to tell listeners that a test suite is about to finish.
|
void |
fireTestSuiteStarted(Description description)
Invoke to tell listeners that a test suite is about to start.
|
void |
pleaseStop()
Ask that the tests run stop before starting the next test.
|
void |
removeListener(RunListener listener)
Internal use only
|
(package private) RunListener |
wrapIfNotThreadSafe(RunListener listener)
Wraps the given listener with
SynchronizedRunListener if
it is not annotated with RunListener.ThreadSafe . |
private final java.util.List<RunListener> listeners
private volatile boolean pleaseStop
public void addListener(RunListener listener)
public void removeListener(RunListener listener)
RunListener wrapIfNotThreadSafe(RunListener listener)
SynchronizedRunListener
if
it is not annotated with RunListener.ThreadSafe
.public void fireTestRunStarted(Description description)
public void fireTestRunFinished(Result result)
public void fireTestSuiteStarted(Description description)
Description
then fireTestSuiteFinished(Description)
MUST
be called for the same Description
.description
- the description of the suite test (generally a class name)public void fireTestSuiteFinished(Description description)
fireTestSuiteStarted(Description)
as listeners are likely to expect them to come in pairs.description
- the description of the suite test (generally a class name)public void fireTestStarted(Description description) throws StoppedByUserException
description
- the description of the atomic test (generally a class and method name)StoppedByUserException
- thrown if a user has requested that the test run stoppublic void fireTestFailure(Failure failure)
failure
- the description of the test that failed and the exception thrownprivate void fireTestFailures(java.util.List<RunListener> listeners, java.util.List<Failure> failures)
public void fireTestAssumptionFailed(Failure failure)
failure
- the description of the test that failed and the
AssumptionViolatedException
thrownpublic void fireTestIgnored(Description description)
description
- the description of the ignored testpublic void fireTestFinished(Description description)
fireTestStarted(Description)
as listeners are likely to expect them to come in pairs.description
- the description of the test that finishedpublic void pleaseStop()
RunNotifier
is the only object guaranteed
to be shared amongst the many runners involved.public void addFirstListener(RunListener listener)