Class TextRunListener
- java.lang.Object
-
- org.junit.runner.notification.RunListener
-
- eu.simuline.testhelpers.ExtRunListener
-
- eu.simuline.testhelpers.TextRunListener
-
public final class TextRunListener extends ExtRunListener
A simple RunListener which notifies of the events while running tests by text output. Created: Wed Jun 7 16:41:14 2006- Version:
- 1.0
- Author:
- Ernst Reissner
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.junit.runner.notification.RunListener
RunListener.ThreadSafe
-
-
Constructor Summary
Constructors Constructor Description TextRunListener()
Creates a newTextRunListener
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
desc2string(Description desc)
Returns a string representation ofdesc
: For atomic tests the display name, for suites an xml-style description.void
testAssumptionFailure(Failure failure)
Called when an atomic test flags that it assumes a condition that is false.void
testClassStructureLoaded(Description desc)
Invoked if a test class is loaded defining a testsuite described bydesc
.void
testFailure(Failure failure)
Called when an atomic test fails to execute properly throwing a Throwable, or when a listener throws an exception.void
testFinished(Description desc)
Called when an atomic test has finished, whether the test succeeds or fails.void
testIgnored(Description desc)
Called when a test will not be run, generally because a test method is annotated withIgnore
.void
testRunAborted()
Invoked for stop and for break originated by the user.void
testRunFinished(Result result)
Called when all tests of the suite announced bytestRunStarted(Description)
have finished.void
testRunStarted(Description desc)
Called before any tests of a suite described bydesc
have been run.void
testStarted(Description desc)
Called when an atomic test is about to be started.void
testSuiteFinished(Description desc)
Called when a test suite has finished, whether the test suite succeeds or fails.void
testSuiteStarted(Description desc)
Called when a test suite is about to be started.
-
-
-
Method Detail
-
desc2string
private static java.lang.String desc2string(Description desc)
Returns a string representation ofdesc
: For atomic tests the display name, for suites an xml-style description.
-
testRunStarted
public void testRunStarted(Description desc) throws java.lang.Exception
Called before any tests of a suite described bydesc
have been run. This may be called on an arbitrary thread.- Overrides:
testRunStarted
in classRunListener
- Parameters:
desc
- describes the suite of tests to be run.- Throws:
java.lang.Exception
-
testRunFinished
public void testRunFinished(Result result) throws java.lang.Exception
Called when all tests of the suite announced bytestRunStarted(Description)
have finished. This may be called on an arbitrary thread.Prints a statistics on the result of the test suite to the standard output.
- Overrides:
testRunFinished
in classRunListener
- Parameters:
result
- the summary of the outcoming of the suite of tests run, including all the tests that failed- Throws:
java.lang.Exception
-
testSuiteStarted
public void testSuiteStarted(Description desc) throws java.lang.Exception
Called when a test suite is about to be started. If this method is called for a givenDescription
, thentestSuiteFinished(Description)
will also be called for the sameDescription
.Note that not all runners will call this method, so runners should be prepared to handle
testStarted(Description)
calls for tests where there was no correspondingtestSuiteStarted(Description)
call for the parentDescription
.- Overrides:
testSuiteStarted
in classExtRunListener
- Parameters:
desc
- the description of the test suite that is about to be run (generally a class name)- Throws:
java.lang.Exception
- Since:
- 4.13
-
testSuiteFinished
public void testSuiteFinished(Description desc) throws java.lang.Exception
Called when a test suite has finished, whether the test suite succeeds or fails. This method will not be called for a givenDescription
unlesstestSuiteStarted(Description)
was called for the sameDescription
.- Overrides:
testSuiteFinished
in classExtRunListener
- Parameters:
desc
- the description of the test suite that just ran- Throws:
java.lang.Exception
- Since:
- 4.13
-
testStarted
public void testStarted(Description desc) throws java.lang.Exception
Called when an atomic test is about to be started. An ignored test is never started.- Overrides:
testStarted
in classRunListener
- Parameters:
desc
- the description of the test that is about to be run (generally a class and method name)- Throws:
java.lang.Exception
- See Also:
testIgnored(Description)
-
testFinished
public void testFinished(Description desc) throws java.lang.Exception
Called when an atomic test has finished, whether the test succeeds or fails. This method must be invoked after a test has been started which was indicated bytestStarted(Description)
before. An ignored test is never finished.- Overrides:
testFinished
in classRunListener
- Parameters:
desc
- the description of the test that just ran- Throws:
java.lang.Exception
- See Also:
testIgnored(Description)
-
testFailure
public void testFailure(Failure failure) throws java.lang.Exception
Called when an atomic test fails to execute properly throwing a Throwable, or when a listener throws an exception.In the case of a failure of an atomic test, this method is invoked after
testStarted(Description)
and beforetestFinished(Description)
with the according description offailure
from the same thread that calledtestStarted(Description)
. In case of a failed assumption, instead of this methodtestAssumptionFailure(Failure)
is invoked for the according test.In the case of a listener throwing an exception, this method will be called with the description of
failure
given byDescription.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 or indicates that a listener has thrown an exception and the according exception.- Throws:
java.lang.Exception
-
testAssumptionFailure
public void testAssumptionFailure(Failure failure)
Called when an atomic test flags that it assumes a condition that is false. This is treated as ignored with the description of the failure. This method is invoked aftertestStarted(Description)
and beforetestFinished(Description)
with the according description offailure
. A failed assertion does not count as a failure and sotestFailure(Failure)
is not invoked for the according test.CAUTION: Although a failed assertion is like an ignored test,
testRunFinished(Result)
does not count this as ignored test but rather than a passed test.- Overrides:
testAssumptionFailure
in classRunListener
- Parameters:
failure
- describes the test that failed and theAssumptionViolatedException
that was thrown.- See Also:
testIgnored(Description)
-
testIgnored
public void testIgnored(Description desc) throws java.lang.Exception
Called when a test will not be run, generally because a test method is annotated withIgnore
. This implies that neithertestStarted(Description)
nortestFinished(Description)
are invoked for the according test. This in turn implies that neithertestFailure(Failure)
nortestAssumptionFailure(Failure)
are invoked.- Overrides:
testIgnored
in classRunListener
- Parameters:
desc
- describes the test that will not be run- Throws:
java.lang.Exception
-
testRunAborted
public void testRunAborted()
Invoked for stop and for break originated by the user.- Overrides:
testRunAborted
in classExtRunListener
-
testClassStructureLoaded
public void testClassStructureLoaded(Description desc)
Invoked if a test class is loaded defining a testsuite described bydesc
.- Overrides:
testClassStructureLoaded
in classExtRunListener
-
-