Class ConcurrentRunListener
java.lang.Object
org.apache.maven.surefire.junitcore.ConcurrentRunListener
- All Implemented Interfaces:
ConsoleOutputReceiver,RunListener
- Direct Known Subclasses:
ClassesParallelRunListener,MethodsParallelRunListener
public abstract class ConcurrentRunListener
extends Object
implements RunListener, ConsoleOutputReceiver
Handles responses from concurrent junit
Stuff to remember about JUnit threading: parallel=classes; beforeClass/afterClass, constructor and all tests method run on same thread parallel=methods; beforeClass/afterClass run on main thread, constructor + each test method run on same thread parallel=both; same as parallel=methods
Stuff to remember about JUnit threading: parallel=classes; beforeClass/afterClass, constructor and all tests method run on same thread parallel=methods; beforeClass/afterClass run on main thread, constructor + each test method run on same thread parallel=both; same as parallel=methods
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConsoleStreamprivate final ThreadLocal<RunListener>private final boolean -
Constructor Summary
ConstructorsConstructorDescriptionConcurrentRunListener(ReporterFactory reporterFactory, ConsoleStream consoleStream, boolean reportImmediately, Map<String, TestSet> classMethodCounts) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcheckIfTestSetCanBeReported(TestSet testSetForTest) static ConcurrentRunListenercreateInstance(Map<String, TestSet> classMethodCounts, ReporterFactory reporterFactory, boolean parallelClasses, boolean parallelBoth, ConsoleStream consoleStream) private TestMethodgetOrCreateThreadAttachedTestMethod(ReportEntry description) (package private) RunListenerprivate TestSetgetTestSet(ReportEntry description) Marks the listener with run mode, e.g.voidtestAssumptionFailure(ReportEntry failure) Event fired when a test assumption failure was encountered.voidtestError(ReportEntry failure) Event fired when a test ended with an error (non anticipated problem)voidEvent fired skipping an execution of remaining test-set in other fork(s); or does nothing if no forks.voidtestFailed(ReportEntry failure) Event fired when a test ended with a failure (anticipated problem)voidtestSetCompleted(TestSetReportEntry result) Indicates end of a given test-setvoidtestSetStarting(TestSetReportEntry description) Indicates the start of a given test-setvoidtestSkipped(ReportEntry description) Event fired when a test is skippedvoidtestStarting(ReportEntry description) Event fired when a test is about to startvoidtestSucceeded(ReportEntry report) Event fired when a test ended successfullyvoidwriteTestOutput(String output, boolean newLine, boolean stdout) Forwards process output from the running test-case into the reporting system
-
Field Details
-
classMethodCounts
-
reporterManagerThreadLocal
-
reportImmediately
private final boolean reportImmediately -
consoleStream
-
-
Constructor Details
-
ConcurrentRunListener
ConcurrentRunListener(ReporterFactory reporterFactory, ConsoleStream consoleStream, boolean reportImmediately, Map<String, TestSet> classMethodCounts) throws TestSetFailedException- Throws:
TestSetFailedException
-
-
Method Details
-
testSetStarting
Description copied from interface:RunListenerIndicates the start of a given test-set- Specified by:
testSetStartingin interfaceRunListener- Parameters:
description- the report entry describing the testset
-
testSetCompleted
Description copied from interface:RunListenerIndicates end of a given test-set- Specified by:
testSetCompletedin interfaceRunListener- Parameters:
result- the report entry describing the testset
-
testFailed
Description copied from interface:RunListenerEvent fired when a test ended with a failure (anticipated problem)- Specified by:
testFailedin interfaceRunListener- Parameters:
failure- The report entry to log for
-
testError
Description copied from interface:RunListenerEvent fired when a test ended with an error (non anticipated problem)- Specified by:
testErrorin interfaceRunListener- Parameters:
failure- The report entry to log for
-
testSkipped
Description copied from interface:RunListenerEvent fired when a test is skipped- Specified by:
testSkippedin interfaceRunListener- Parameters:
description- The report entry to log for
-
testExecutionSkippedByUser
public void testExecutionSkippedByUser()Description copied from interface:RunListenerEvent fired skipping an execution of remaining test-set in other fork(s); or does nothing if no forks. The method is called bySurefireProvider.(The event is fired after the Nth test failed to signal skipping the rest of test-set.)
- Specified by:
testExecutionSkippedByUserin interfaceRunListener
-
markAs
Description copied from interface:RunListenerMarks the listener with run mode, e.g. normal run or re-run.- Specified by:
markAsin interfaceRunListener- Parameters:
currentRunMode- set current run- Returns:
- previous run mode; never returns null
-
testAssumptionFailure
Description copied from interface:RunListenerEvent fired when a test assumption failure was encountered. An assumption failure indicates that the test is not relevant- Specified by:
testAssumptionFailurein interfaceRunListener- Parameters:
failure- The report entry to log for
-
testStarting
Description copied from interface:RunListenerEvent fired when a test is about to start- Specified by:
testStartingin interfaceRunListener- Parameters:
description- The report entry to log for
-
testSucceeded
Description copied from interface:RunListenerEvent fired when a test ended successfully- Specified by:
testSucceededin interfaceRunListener- Parameters:
report- The report entry to log for
-
getOrCreateThreadAttachedTestMethod
-
checkIfTestSetCanBeReported
-
getTestSet
-
getRunListener
RunListener getRunListener() -
createInstance
public static ConcurrentRunListener createInstance(Map<String, TestSet> classMethodCounts, ReporterFactory reporterFactory, boolean parallelClasses, boolean parallelBoth, ConsoleStream consoleStream) throws TestSetFailedException- Throws:
TestSetFailedException
-
writeTestOutput
Description copied from interface:ConsoleOutputReceiverForwards process output from the running test-case into the reporting system- Specified by:
writeTestOutputin interfaceConsoleOutputReceiver- Parameters:
output- stdout/sterr output from running testsnewLine- print on new linestdout- Indicates if this is stdout
-