From b1b2c24bb34b3d0b3a8ba717b01494f1d286e7c7 Mon Sep 17 00:00:00 2001 From: Marc Philipp Date: Sun, 4 Feb 2024 18:02:38 +0100 Subject: [PATCH] Document that TestExecutionListeners cannot fail test execution Resolves #3591. (cherry picked from commit 3fac3e9db8f8db558413348196f129038a46d35b) --- .../org/junit/platform/launcher/TestExecutionListener.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/TestExecutionListener.java b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/TestExecutionListener.java index 548395c43cfa..2b8ae2dd98f5 100644 --- a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/TestExecutionListener.java +++ b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/TestExecutionListener.java @@ -13,6 +13,7 @@ import static org.apiguardian.api.API.Status.STABLE; import org.apiguardian.api.API; +import org.junit.platform.commons.util.UnrecoverableExceptions; import org.junit.platform.engine.TestExecutionResult; import org.junit.platform.engine.TestExecutionResult.Status; import org.junit.platform.engine.reporting.ReportEntry; @@ -30,6 +31,12 @@ * events are called in reverse order. Test case execution won't start before * all {@link #executionStarted(TestIdentifier)} calls have returned. * + *

If an exception is thrown by an implementation of a method of this + * interface, the exception will be caught and logged unless it is deemed + * {@linkplain UnrecoverableExceptions unrecoverable}. In consequence, a + * {@code TestExecutionListener} cannot cause test execution to fail or abort it + * early by throwing an exception. + * *

JUnit provides two example implementations. * *