Class JUnit4RunListener
- java.lang.Object
-
- org.junit.runner.notification.RunListener
-
- org.apache.maven.surefire.common.junit4.JUnit4RunListener
-
- All Implemented Interfaces:
TestOutputReceiver<OutputReportEntry>,RunModeSetter
- Direct Known Subclasses:
JUnitCoreRunListener,NonConcurrentRunListener
public class JUnit4RunListener extends org.junit.runner.notification.RunListener implements TestOutputReceiver<OutputReportEntry>, RunModeSetter
RunListener for JUnit4, delegates to our own RunListener
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassMethodIndexerclassMethodIndexerprivate java.lang.ThreadLocal<java.lang.Boolean>failureFlagThis flag is set after a failure has occurred so that aRunListener.testSucceeded(org.apache.maven.surefire.api.report.ReportEntry)event is not fired.protected TestReportListener<TestOutputReportEntry>reporterprivate RunModerunMode
-
Constructor Summary
Constructors Constructor Description JUnit4RunListener(TestReportListener<TestOutputReportEntry> reporter)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SimpleReportEntrycreateReportEntry(org.junit.runner.Description description)protected StackTraceWritercreateStackTraceWriter(org.junit.runner.notification.Failure failure)ConsoleLoggergetConsoleLogger()protected RunModegetRunMode()static voidrethrowAnyTestMechanismFailures(org.junit.runner.Result run)voidsetRunMode(RunMode runMode)voidtestAssumptionFailure(org.junit.runner.notification.Failure failure)voidtestExecutionSkippedByUser()Delegates toRunListener.testExecutionSkippedByUser().voidtestFailure(org.junit.runner.notification.Failure failure)Called when a specific test has failed.voidtestFinished(org.junit.runner.Description description)Called after a specific test has finished.voidtestIgnored(org.junit.runner.Description description)Called when a specific test has been skipped (for whatever reason).voidtestStarted(org.junit.runner.Description description)Called when a specific test has started.voidwriteTestOutput(OutputReportEntry reportEntry)Forwards process output from the running test-case into the reporting system
-
-
-
Field Detail
-
classMethodIndexer
protected final ClassMethodIndexer classMethodIndexer
-
reporter
protected final TestReportListener<TestOutputReportEntry> reporter
-
runMode
private volatile RunMode runMode
-
failureFlag
private final java.lang.ThreadLocal<java.lang.Boolean> failureFlag
This flag is set after a failure has occurred so that aRunListener.testSucceeded(org.apache.maven.surefire.api.report.ReportEntry)event is not fired. This is necessary because JUnit4 always fires aRunListener.testRunFinished(Result)event-- even if there was a failure.
-
-
Constructor Detail
-
JUnit4RunListener
public JUnit4RunListener(TestReportListener<TestOutputReportEntry> reporter)
Constructor.- Parameters:
reporter- the reporter to log testing events to
-
-
Method Detail
-
getConsoleLogger
public final ConsoleLogger getConsoleLogger()
-
setRunMode
public void setRunMode(RunMode runMode)
- Specified by:
setRunModein interfaceRunModeSetter
-
getRunMode
protected final RunMode getRunMode()
-
testIgnored
public void testIgnored(org.junit.runner.Description description) throws java.lang.ExceptionCalled when a specific test has been skipped (for whatever reason).- Overrides:
testIgnoredin classorg.junit.runner.notification.RunListener- Throws:
java.lang.Exception- See Also:
RunListener.testIgnored(org.junit.runner.Description)
-
testStarted
public void testStarted(org.junit.runner.Description description) throws java.lang.ExceptionCalled when a specific test has started.- Overrides:
testStartedin classorg.junit.runner.notification.RunListener- Throws:
java.lang.Exception- See Also:
RunListener.testStarted(org.junit.runner.Description)
-
testFailure
public void testFailure(org.junit.runner.notification.Failure failure) throws java.lang.ExceptionCalled when a specific test has failed.- Overrides:
testFailurein classorg.junit.runner.notification.RunListener- Throws:
java.lang.Exception- See Also:
RunListener.testFailure(org.junit.runner.notification.Failure)
-
testAssumptionFailure
public void testAssumptionFailure(org.junit.runner.notification.Failure failure)
- Overrides:
testAssumptionFailurein classorg.junit.runner.notification.RunListener
-
testFinished
public void testFinished(org.junit.runner.Description description) throws java.lang.ExceptionCalled after a specific test has finished.- Overrides:
testFinishedin classorg.junit.runner.notification.RunListener- Throws:
java.lang.Exception- See Also:
RunListener.testFinished(org.junit.runner.Description)
-
testExecutionSkippedByUser
public void testExecutionSkippedByUser()
Delegates toRunListener.testExecutionSkippedByUser().
-
createStackTraceWriter
protected StackTraceWriter createStackTraceWriter(org.junit.runner.notification.Failure failure)
-
createReportEntry
protected SimpleReportEntry createReportEntry(org.junit.runner.Description description)
-
rethrowAnyTestMechanismFailures
public static void rethrowAnyTestMechanismFailures(org.junit.runner.Result run) throws TestSetFailedException- Throws:
TestSetFailedException
-
writeTestOutput
public void writeTestOutput(OutputReportEntry reportEntry)
Description copied from interface:TestOutputReceiverForwards process output from the running test-case into the reporting system- Specified by:
writeTestOutputin interfaceTestOutputReceiver<OutputReportEntry>- Parameters:
reportEntry- wraps test output with descriptive information of the output
-
-