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 java.lang.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
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,TestSet>
classMethodCounts
private ConsoleStream
consoleStream
private java.lang.ThreadLocal<RunListener>
reporterManagerThreadLocal
private boolean
reportImmediately
-
Constructor Summary
Constructors Constructor Description ConcurrentRunListener(ReporterFactory reporterFactory, ConsoleStream consoleStream, boolean reportImmediately, java.util.Map<java.lang.String,TestSet> classMethodCounts)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
checkIfTestSetCanBeReported(TestSet testSetForTest)
static ConcurrentRunListener
createInstance(java.util.Map<java.lang.String,TestSet> classMethodCounts, ReporterFactory reporterFactory, boolean parallelClasses, boolean parallelBoth, ConsoleStream consoleStream)
private TestMethod
getOrCreateThreadAttachedTestMethod(ReportEntry description)
(package private) RunListener
getRunListener()
private TestSet
getTestSet(ReportEntry description)
RunMode
markAs(RunMode currentRunMode)
Marks the listener with run mode, e.g.void
testAssumptionFailure(ReportEntry failure)
Event fired when a test assumption failure was encountered.void
testError(ReportEntry failure)
Event fired when a test ended with an error (non anticipated problem)void
testExecutionSkippedByUser()
Event fired skipping an execution of remaining test-set in other fork(s); or does nothing if no forks.void
testFailed(ReportEntry failure)
Event fired when a test ended with a failure (anticipated problem)void
testSetCompleted(TestSetReportEntry result)
Indicates end of a given test-setvoid
testSetStarting(TestSetReportEntry description)
Indicates the start of a given test-setvoid
testSkipped(ReportEntry description)
Event fired when a test is skippedvoid
testStarting(ReportEntry description)
Event fired when a test is about to startvoid
testSucceeded(ReportEntry report)
Event fired when a test ended successfullyvoid
writeTestOutput(java.lang.String output, boolean newLine, boolean stdout)
Forwards process output from the running test-case into the reporting system
-
-
-
Field Detail
-
classMethodCounts
private final java.util.Map<java.lang.String,TestSet> classMethodCounts
-
reporterManagerThreadLocal
private final java.lang.ThreadLocal<RunListener> reporterManagerThreadLocal
-
reportImmediately
private final boolean reportImmediately
-
consoleStream
private final ConsoleStream consoleStream
-
-
Constructor Detail
-
ConcurrentRunListener
ConcurrentRunListener(ReporterFactory reporterFactory, ConsoleStream consoleStream, boolean reportImmediately, java.util.Map<java.lang.String,TestSet> classMethodCounts) throws TestSetFailedException
- Throws:
TestSetFailedException
-
-
Method Detail
-
testSetStarting
public void testSetStarting(TestSetReportEntry description)
Description copied from interface:RunListener
Indicates the start of a given test-set- Specified by:
testSetStarting
in interfaceRunListener
- Parameters:
description
- the report entry describing the testset
-
testSetCompleted
public void testSetCompleted(TestSetReportEntry result)
Description copied from interface:RunListener
Indicates end of a given test-set- Specified by:
testSetCompleted
in interfaceRunListener
- Parameters:
result
- the report entry describing the testset
-
testFailed
public void testFailed(ReportEntry failure)
Description copied from interface:RunListener
Event fired when a test ended with a failure (anticipated problem)- Specified by:
testFailed
in interfaceRunListener
- Parameters:
failure
- The report entry to log for
-
testError
public void testError(ReportEntry failure)
Description copied from interface:RunListener
Event fired when a test ended with an error (non anticipated problem)- Specified by:
testError
in interfaceRunListener
- Parameters:
failure
- The report entry to log for
-
testSkipped
public void testSkipped(ReportEntry description)
Description copied from interface:RunListener
Event fired when a test is skipped- Specified by:
testSkipped
in interfaceRunListener
- Parameters:
description
- The report entry to log for
-
testExecutionSkippedByUser
public void testExecutionSkippedByUser()
Description copied from interface:RunListener
Event 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:
testExecutionSkippedByUser
in interfaceRunListener
-
markAs
public RunMode markAs(RunMode currentRunMode)
Description copied from interface:RunListener
Marks the listener with run mode, e.g. normal run or re-run.- Specified by:
markAs
in interfaceRunListener
- Parameters:
currentRunMode
- set current run- Returns:
- previous run mode; never returns null
-
testAssumptionFailure
public void testAssumptionFailure(ReportEntry failure)
Description copied from interface:RunListener
Event fired when a test assumption failure was encountered. An assumption failure indicates that the test is not relevant- Specified by:
testAssumptionFailure
in interfaceRunListener
- Parameters:
failure
- The report entry to log for
-
testStarting
public void testStarting(ReportEntry description)
Description copied from interface:RunListener
Event fired when a test is about to start- Specified by:
testStarting
in interfaceRunListener
- Parameters:
description
- The report entry to log for
-
testSucceeded
public void testSucceeded(ReportEntry report)
Description copied from interface:RunListener
Event fired when a test ended successfully- Specified by:
testSucceeded
in interfaceRunListener
- Parameters:
report
- The report entry to log for
-
getOrCreateThreadAttachedTestMethod
private TestMethod getOrCreateThreadAttachedTestMethod(ReportEntry description)
-
checkIfTestSetCanBeReported
protected abstract void checkIfTestSetCanBeReported(TestSet testSetForTest)
-
getTestSet
private TestSet getTestSet(ReportEntry description)
-
getRunListener
RunListener getRunListener()
-
createInstance
public static ConcurrentRunListener createInstance(java.util.Map<java.lang.String,TestSet> classMethodCounts, ReporterFactory reporterFactory, boolean parallelClasses, boolean parallelBoth, ConsoleStream consoleStream) throws TestSetFailedException
- Throws:
TestSetFailedException
-
writeTestOutput
public void writeTestOutput(java.lang.String output, boolean newLine, boolean stdout)
Description copied from interface:ConsoleOutputReceiver
Forwards process output from the running test-case into the reporting system- Specified by:
writeTestOutput
in interfaceConsoleOutputReceiver
- Parameters:
output
- stdout/sterr output from running testsnewLine
- print on new linestdout
- Indicates if this is stdout
-
-