Package uk.ac.ebi.utils.test.junit
Class TestOutputDecorator
java.lang.Object
org.junit.runner.notification.RunListener
uk.ac.ebi.utils.test.junit.TestOutputDecorator
- All Implemented Interfaces:
org.junit.rules.TestRule
public class TestOutputDecorator
extends org.junit.runner.notification.RunListener
implements org.junit.rules.TestRule
# An output decorator for JUnit
Logs a nice header with the test name before the test and a similar trailer
afterward.
This can be used in two ways. One is as a
TestRule
, pretty much the same way you would use
ExternalResource
. Another option is to add this listener to your runner of choice in order to be invoked
automatically for all the tests run via that runner.
For instance, see
[here](http://maven.apache.org/plugins/maven-surefire-plugin/examples/junit.html#Using_custom_listeners_and_reporters)
for what concerns Maven/Surefire. The JUtils's POM is itself another example of that.
**WARNING**: this uses SLF4J, you need to enable the INFO level to see anything.
- date
- Jan 27, 2012
- Author:
- brandizi
-
Nested Class Summary
Nested classes/interfaces inherited from class org.junit.runner.notification.RunListener
org.junit.runner.notification.RunListener.ThreadSafe
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) You can use this class either as a listener, or aRule
, so we have this method too, to be called by JUnit in the second case.void
testFinished
(org.junit.runner.Description description) void
testStarted
(org.junit.runner.Description description) Methods inherited from class org.junit.runner.notification.RunListener
testAssumptionFailure, testFailure, testIgnored, testRunFinished, testRunStarted, testSuiteFinished, testSuiteStarted
-
Constructor Details
-
TestOutputDecorator
public TestOutputDecorator()
-
-
Method Details
-
testStarted
- Overrides:
testStarted
in classorg.junit.runner.notification.RunListener
- Throws:
Exception
-
testFinished
- Overrides:
testFinished
in classorg.junit.runner.notification.RunListener
- Throws:
Exception
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) You can use this class either as a listener, or aRule
, so we have this method too, to be called by JUnit in the second case.- Specified by:
apply
in interfaceorg.junit.rules.TestRule
-