Class SynchronizedRunListener
RunListener
implementations that synchronizes
calls to the delegate.
This class synchronizes all listener calls on a RunNotifier instance. This is done because prior to JUnit 4.12, all listeners were called in a synchronized block in RunNotifier, so no two listeners were ever called concurrently. If we instead made the methods here synchronized, clients that added multiple listeners that called common code might see issues due to the reduced synchronization.
- Since:
- 4.12
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.junit.runner.notification.RunListener
RunListener.ThreadSafe
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
void
testAssumptionFailure
(Failure failure) Called when an atomic test flags that it assumes a condition that is falsevoid
testFailure
(Failure failure) Called when an atomic test fails, or when a listener throws an exception.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 withIgnore
.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.void
testSuiteFinished
(Description description) Called when a test suite has finished, whether the test suite succeeds or fails.void
testSuiteStarted
(Description description) Called when a test suite is about to be started.toString()
-
Field Details
-
listener
-
monitor
-
-
Constructor Details
-
SynchronizedRunListener
SynchronizedRunListener(RunListener listener, Object monitor)
-
-
Method Details
-
testRunStarted
Description copied from class:RunListener
Called before any tests have been run. This may be called on an arbitrary thread.- Overrides:
testRunStarted
in classRunListener
- Parameters:
description
- describes the tests to be run- Throws:
Exception
-
testRunFinished
Description copied from class:RunListener
Called when all tests have finished. This may be called on an arbitrary thread.- Overrides:
testRunFinished
in classRunListener
- Parameters:
result
- the summary of the test run, including all the tests that failed- Throws:
Exception
-
testSuiteStarted
Called when a test suite is about to be started. If this method is called for a givenDescription
, thenRunListener.testSuiteFinished(Description)
will also be called for the sameDescription
.Note that not all runners will call this method, so runners should be prepared to handle
Synchronized decorator forRunListener.testStarted(Description)
calls for tests where there was no correspondingtestSuiteStarted()
call for the parentDescription
.RunListener.testSuiteStarted(Description)
.- Overrides:
testSuiteStarted
in classRunListener
- Parameters:
description
- the description of the test suite that is about to be run (generally a class name).- Throws:
Exception
- if any occurs.- Since:
- 4.13
-
testSuiteFinished
Called when a test suite has finished, whether the test suite succeeds or fails. This method will not be called for a givenDescription
unlessRunListener.testSuiteStarted(Description)
was called for the same @code Description}. Synchronized decorator forRunListener.testSuiteFinished(Description)
.- Overrides:
testSuiteFinished
in classRunListener
- Parameters:
description
- the description of the test suite that just ran.- Throws:
Exception
- Since:
- 4.13
-
testStarted
Description copied from class:RunListener
Called when an atomic test is about to be started.- Overrides:
testStarted
in classRunListener
- Parameters:
description
- the description of the test that is about to be run (generally a class and method name)- Throws:
Exception
-
testFinished
Description copied from class:RunListener
Called when an atomic test has finished, whether the test succeeds or fails.- Overrides:
testFinished
in classRunListener
- Parameters:
description
- the description of the test that just ran- Throws:
Exception
-
testFailure
Description copied from class:RunListener
Called when an atomic test fails, or when a listener throws an exception.In the case of a failure of an atomic test, this method will be called with the same
Description
passed toRunListener.testStarted(Description)
, from the same thread that calledRunListener.testStarted(Description)
.In the case of a listener throwing an exception, this will be called with a
Description
ofDescription.TEST_MECHANISM
, and may be called on an arbitrary thread.- Overrides:
testFailure
in classRunListener
- Parameters:
failure
- describes the test that failed and the exception that was thrown- Throws:
Exception
-
testAssumptionFailure
Description copied from class:RunListener
Called when an atomic test flags that it assumes a condition that is false- Overrides:
testAssumptionFailure
in classRunListener
- Parameters:
failure
- describes the test that failed and theAssumptionViolatedException
that was thrown
-
testIgnored
Description copied from class:RunListener
Called when a test will not be run, generally because a test method is annotated withIgnore
.- Overrides:
testIgnored
in classRunListener
- Parameters:
description
- describes the test that will not be run- Throws:
Exception
-
hashCode
public int hashCode() -
equals
-
toString
-