Class LoggingListener

java.lang.Object
org.junit.platform.launcher.listeners.LoggingListener
All Implemented Interfaces:
TestExecutionListener

@API(status=MAINTAINED, since="1.0") public class LoggingListener extends Object implements TestExecutionListener
Simple TestExecutionListener for logging informational messages for all events via a BiConsumer that consumes Throwable and Supplier<String>.
Since:
1.0
See Also:
forJavaUtilLogging(), forJavaUtilLogging(Level), LoggingListener(BiConsumer)
  • Method Details

    • forJavaUtilLogging

      public static LoggingListener forJavaUtilLogging()
      Create a LoggingListener which delegates to a Logger using a log level of FINE.
      See Also:
      forJavaUtilLogging(Level), forBiConsumer(BiConsumer)
    • forJavaUtilLogging

      public static LoggingListener forJavaUtilLogging(Level logLevel)
      Create a LoggingListener which delegates to a Logger using the supplied log level.
      Parameters:
      logLevel - the log level to use; never null
      See Also:
      forJavaUtilLogging(), forBiConsumer(BiConsumer)
    • forBiConsumer

      public static LoggingListener forBiConsumer(BiConsumer<Throwable,​Supplier<String>> logger)
      Create a LoggingListener which delegates to the supplied BiConsumer for consumption of logging messages.

      The BiConsumer's arguments are a Throwable (potentially null) and a Supplier (never null) for the log message.

      Parameters:
      logger - a logger implemented as a BiConsumer; never null
      See Also:
      forJavaUtilLogging(), forJavaUtilLogging(Level)
    • testPlanExecutionStarted

      public void testPlanExecutionStarted(TestPlan testPlan)
      Description copied from interface: TestExecutionListener
      Called when the execution of the TestPlan has started, before any test has been executed.
      Specified by:
      testPlanExecutionStarted in interface TestExecutionListener
      Parameters:
      testPlan - describes the tree of tests about to be executed
    • testPlanExecutionFinished

      public void testPlanExecutionFinished(TestPlan testPlan)
      Description copied from interface: TestExecutionListener
      Called when the execution of the TestPlan has finished, after all tests have been executed.
      Specified by:
      testPlanExecutionFinished in interface TestExecutionListener
      Parameters:
      testPlan - describes the tree of tests that have been executed
    • dynamicTestRegistered

      public void dynamicTestRegistered(TestIdentifier testIdentifier)
      Description copied from interface: TestExecutionListener
      Called when a new, dynamic TestIdentifier has been registered.

      A dynamic test is a test that is not known a-priori and therefore not contained in the original TestPlan.

      Specified by:
      dynamicTestRegistered in interface TestExecutionListener
      Parameters:
      testIdentifier - the identifier of the newly registered test or container
    • executionStarted

      public void executionStarted(TestIdentifier testIdentifier)
      Description copied from interface: TestExecutionListener
      Called when the execution of a leaf or subtree of the TestPlan is about to be started.

      The TestIdentifier may represent a test or a container.

      This method will only be called if the test or container has not been skipped.

      This method will be called for a container TestIdentifier before starting or skipping any of its children.

      Specified by:
      executionStarted in interface TestExecutionListener
      Parameters:
      testIdentifier - the identifier of the started test or container
    • executionSkipped

      public void executionSkipped(TestIdentifier testIdentifier, String reason)
      Description copied from interface: TestExecutionListener
      Called when the execution of a leaf or subtree of the TestPlan has been skipped.

      The TestIdentifier may represent a test or a container. In the case of a container, no listener methods will be called for any of its descendants.

      A skipped test or subtree of tests will never be reported as started or finished.

      Specified by:
      executionSkipped in interface TestExecutionListener
      Parameters:
      testIdentifier - the identifier of the skipped test or container
      reason - a human-readable message describing why the execution has been skipped
    • executionFinished

      public void executionFinished(TestIdentifier testIdentifier, org.junit.platform.engine.TestExecutionResult testExecutionResult)
      Description copied from interface: TestExecutionListener
      Called when the execution of a leaf or subtree of the TestPlan has finished, regardless of the outcome.

      The TestIdentifier may represent a test or a container.

      This method will only be called if the test or container has not been skipped.

      This method will be called for a container TestIdentifier after all of its children have been skipped or have finished.

      The TestExecutionResult describes the result of the execution for the supplied TestIdentifier. The result does not include or aggregate the results of its children. For example, a container with a failing test will be reported as SUCCESSFUL even if one or more of its children are reported as FAILED.

      Specified by:
      executionFinished in interface TestExecutionListener
      Parameters:
      testIdentifier - the identifier of the finished test or container
      testExecutionResult - the (unaggregated) result of the execution for the supplied TestIdentifier
      See Also:
      TestExecutionResult