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 java.lang.Object implements TestExecutionListenerSimpleTestExecutionListenerfor logging informational messages for all events via aBiConsumerthat consumesThrowableandSupplier<String>.- Since:
- 1.0
- See Also:
forJavaUtilLogging(),forJavaUtilLogging(Level),LoggingListener(BiConsumer)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddynamicTestRegistered(TestIdentifier testIdentifier)Called when a new, dynamicTestIdentifierhas been registered.voidexecutionFinished(TestIdentifier testIdentifier, org.junit.platform.engine.TestExecutionResult testExecutionResult)Called when the execution of a leaf or subtree of theTestPlanhas finished, regardless of the outcome.voidexecutionSkipped(TestIdentifier testIdentifier, java.lang.String reason)Called when the execution of a leaf or subtree of theTestPlanhas been skipped.voidexecutionStarted(TestIdentifier testIdentifier)Called when the execution of a leaf or subtree of theTestPlanis about to be started.static LoggingListenerforBiConsumer(java.util.function.BiConsumer<java.lang.Throwable,java.util.function.Supplier<java.lang.String>> logger)Create aLoggingListenerwhich delegates to the suppliedBiConsumerfor consumption of logging messages.static LoggingListenerforJavaUtilLogging()Create aLoggingListenerwhich delegates to aLoggerusing a log level ofFINE.static LoggingListenerforJavaUtilLogging(java.util.logging.Level logLevel)Create aLoggingListenerwhich delegates to aLoggerusing the supplied log level.voidtestPlanExecutionFinished(TestPlan testPlan)Called when the execution of theTestPlanhas finished, after all tests have been executed.voidtestPlanExecutionStarted(TestPlan testPlan)Called when the execution of theTestPlanhas started, before any test has been executed.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.junit.platform.launcher.TestExecutionListener
reportingEntryPublished
-
-
-
-
Method Detail
-
forJavaUtilLogging
public static LoggingListener forJavaUtilLogging()
Create aLoggingListenerwhich delegates to aLoggerusing a log level ofFINE.
-
forJavaUtilLogging
public static LoggingListener forJavaUtilLogging(java.util.logging.Level logLevel)
Create aLoggingListenerwhich delegates to aLoggerusing the supplied log level.- Parameters:
logLevel- the log level to use; nevernull- See Also:
forJavaUtilLogging(),forBiConsumer(BiConsumer)
-
forBiConsumer
public static LoggingListener forBiConsumer(java.util.function.BiConsumer<java.lang.Throwable,java.util.function.Supplier<java.lang.String>> logger)
Create aLoggingListenerwhich delegates to the suppliedBiConsumerfor consumption of logging messages.The
BiConsumer'sarguments are aThrowable(potentiallynull) and aSupplier(nevernull) for the log message.- Parameters:
logger- a logger implemented as aBiConsumer; nevernull- See Also:
forJavaUtilLogging(),forJavaUtilLogging(Level)
-
testPlanExecutionStarted
public void testPlanExecutionStarted(TestPlan testPlan)
Description copied from interface:TestExecutionListenerCalled when the execution of theTestPlanhas started, before any test has been executed.- Specified by:
testPlanExecutionStartedin interfaceTestExecutionListener- Parameters:
testPlan- describes the tree of tests about to be executed
-
testPlanExecutionFinished
public void testPlanExecutionFinished(TestPlan testPlan)
Description copied from interface:TestExecutionListenerCalled when the execution of theTestPlanhas finished, after all tests have been executed.- Specified by:
testPlanExecutionFinishedin interfaceTestExecutionListener- Parameters:
testPlan- describes the tree of tests that have been executed
-
dynamicTestRegistered
public void dynamicTestRegistered(TestIdentifier testIdentifier)
Description copied from interface:TestExecutionListenerCalled when a new, dynamicTestIdentifierhas been registered.A dynamic test is a test that is not known a-priori and therefore not contained in the original
TestPlan.- Specified by:
dynamicTestRegisteredin interfaceTestExecutionListener- Parameters:
testIdentifier- the identifier of the newly registered test or container
-
executionStarted
public void executionStarted(TestIdentifier testIdentifier)
Description copied from interface:TestExecutionListenerCalled when the execution of a leaf or subtree of theTestPlanis about to be started.The
TestIdentifiermay 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
TestIdentifierbefore starting or skipping any of its children.- Specified by:
executionStartedin interfaceTestExecutionListener- Parameters:
testIdentifier- the identifier of the started test or container
-
executionSkipped
public void executionSkipped(TestIdentifier testIdentifier, java.lang.String reason)
Description copied from interface:TestExecutionListenerCalled when the execution of a leaf or subtree of theTestPlanhas been skipped.The
TestIdentifiermay 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:
executionSkippedin interfaceTestExecutionListener- Parameters:
testIdentifier- the identifier of the skipped test or containerreason- 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:TestExecutionListenerCalled when the execution of a leaf or subtree of theTestPlanhas finished, regardless of the outcome.The
TestIdentifiermay 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
TestIdentifierafter all of its children have been skipped or have finished.The
TestExecutionResultdescribes the result of the execution for the suppliedTestIdentifier. The result does not include or aggregate the results of its children. For example, a container with a failing test will be reported asSUCCESSFULeven if one or more of its children are reported asFAILED.- Specified by:
executionFinishedin interfaceTestExecutionListener- Parameters:
testIdentifier- the identifier of the finished test or containertestExecutionResult- the (unaggregated) result of the execution for the suppliedTestIdentifier- See Also:
TestExecutionResult
-
-