Class ForkingRunListener

  • All Implemented Interfaces:
    org.apache.maven.plugin.surefire.log.api.ConsoleLogger, ConsoleOutputReceiver, ConsoleStream, RunListener

    public class ForkingRunListener
    extends java.lang.Object
    implements RunListener, org.apache.maven.plugin.surefire.log.api.ConsoleLogger, ConsoleOutputReceiver, ConsoleStream
    Encodes the full output of the test run to the stdout stream.
    This class and the ForkClient contain the full definition of the "wire-level" protocol used by the forked process. The protocol is *not* part of any public api and may change without further notice.
    This class is threadsafe.
    The synchronization in the underlying PrintStream (target instance) is used to preserve thread safety of the output stream. To perform multiple writes/prints for a single request, they must synchronize on "target" variable in this class.
    Author:
    Kristian Rosenvold
    • Field Detail

      • BOOTERCODE_TESTSET_STARTING

        public static final byte BOOTERCODE_TESTSET_STARTING
        See Also:
        Constant Field Values
      • BOOTERCODE_TESTSET_COMPLETED

        public static final byte BOOTERCODE_TESTSET_COMPLETED
        See Also:
        Constant Field Values
      • BOOTERCODE_TEST_STARTING

        public static final byte BOOTERCODE_TEST_STARTING
        See Also:
        Constant Field Values
      • BOOTERCODE_TEST_SUCCEEDED

        public static final byte BOOTERCODE_TEST_SUCCEEDED
        See Also:
        Constant Field Values
      • BOOTERCODE_TEST_FAILED

        public static final byte BOOTERCODE_TEST_FAILED
        See Also:
        Constant Field Values
      • BOOTERCODE_TEST_SKIPPED

        public static final byte BOOTERCODE_TEST_SKIPPED
        See Also:
        Constant Field Values
      • BOOTERCODE_TEST_ASSUMPTIONFAILURE

        public static final byte BOOTERCODE_TEST_ASSUMPTIONFAILURE
        See Also:
        Constant Field Values
      • BOOTERCODE_CONSOLE

        public static final byte BOOTERCODE_CONSOLE
        INFO logger
        See Also:
        ConsoleLogger.info(String), Constant Field Values
      • BOOTERCODE_STOP_ON_NEXT_TEST

        public static final byte BOOTERCODE_STOP_ON_NEXT_TEST
        See Also:
        Constant Field Values
      • BOOTERCODE_ERROR

        public static final byte BOOTERCODE_ERROR
        ERROR logger
        See Also:
        ConsoleLogger.error(String), Constant Field Values
      • BOOTERCODE_DEBUG

        public static final byte BOOTERCODE_DEBUG
        DEBUG logger
        See Also:
        ConsoleLogger.debug(String), Constant Field Values
      • BOOTERCODE_WARNING

        public static final byte BOOTERCODE_WARNING
        WARNING logger
        See Also:
        ConsoleLogger.warning(String), Constant Field Values
    • Constructor Detail

      • ForkingRunListener

        public ForkingRunListener​(java.io.PrintStream target,
                                  int testSetChannelId,
                                  boolean trimStackTraces)
    • Method Detail

      • testSetStarting

        public void testSetStarting​(TestSetReportEntry report)
        Description copied from interface: RunListener
        Indicates the start of a given test-set
        Specified by:
        testSetStarting in interface RunListener
        Parameters:
        report - the report entry describing the testset
      • testSetCompleted

        public void testSetCompleted​(TestSetReportEntry report)
        Description copied from interface: RunListener
        Indicates end of a given test-set
        Specified by:
        testSetCompleted in interface RunListener
        Parameters:
        report - the report entry describing the testset
      • testStarting

        public void testStarting​(ReportEntry report)
        Description copied from interface: RunListener
        Event fired when a test is about to start
        Specified by:
        testStarting in interface RunListener
        Parameters:
        report - 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 interface RunListener
        Parameters:
        report - The report entry to log for
      • testAssumptionFailure

        public void testAssumptionFailure​(ReportEntry report)
        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 interface RunListener
        Parameters:
        report - The report entry to log for
      • testError

        public void testError​(ReportEntry report)
        Description copied from interface: RunListener
        Event fired when a test ended with an error (non anticipated problem)
        Specified by:
        testError in interface RunListener
        Parameters:
        report - The report entry to log for
      • testFailed

        public void testFailed​(ReportEntry report)
        Description copied from interface: RunListener
        Event fired when a test ended with a failure (anticipated problem)
        Specified by:
        testFailed in interface RunListener
        Parameters:
        report - The report entry to log for
      • testSkipped

        public void testSkipped​(ReportEntry report)
        Description copied from interface: RunListener
        Event fired when a test is skipped
        Specified by:
        testSkipped in interface RunListener
        Parameters:
        report - 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 by SurefireProvider.

        (The event is fired after the Nth test failed to signal skipping the rest of test-set.)

        Specified by:
        testExecutionSkippedByUser in interface RunListener
      • writeTestOutput

        public void writeTestOutput​(byte[] buf,
                                    int off,
                                    int len,
                                    boolean stdout)
        Description copied from interface: ConsoleOutputReceiver
        Forwards process output from the running test-case into the reporting system
        Specified by:
        writeTestOutput in interface ConsoleOutputReceiver
        Parameters:
        buf - the buffer to write
        off - offset
        len - len
        stdout - Indicates if this is stdout
      • createHeader

        public static byte[] createHeader​(byte booterCode,
                                          int testSetChannel)
      • isDebugEnabled

        public boolean isDebugEnabled()
        Specified by:
        isDebugEnabled in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • debug

        public void debug​(java.lang.String message)
        Specified by:
        debug in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • isInfoEnabled

        public boolean isInfoEnabled()
        Specified by:
        isInfoEnabled in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • info

        public void info​(java.lang.String message)
        Specified by:
        info in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • isWarnEnabled

        public boolean isWarnEnabled()
        Specified by:
        isWarnEnabled in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • warning

        public void warning​(java.lang.String message)
        Specified by:
        warning in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • isErrorEnabled

        public boolean isErrorEnabled()
        Specified by:
        isErrorEnabled in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • error

        public void error​(java.lang.String message)
        Specified by:
        error in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • error

        public void error​(java.lang.String message,
                          java.lang.Throwable t)
        Specified by:
        error in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • error

        public void error​(java.lang.Throwable t)
        Specified by:
        error in interface org.apache.maven.plugin.surefire.log.api.ConsoleLogger
      • encode

        public static void encode​(java.lang.StringBuilder stringBuilder,
                                  StackTraceWriter stackTraceWriter,
                                  boolean trimStackTraces)
      • println

        public void println​(java.lang.String message)
        Specified by:
        println in interface ConsoleStream
      • println

        public void println​(byte[] buf,
                            int off,
                            int len)
        Specified by:
        println in interface ConsoleStream