Skip to content

Commit

Permalink
Document limitations of interceptor enabling configuration parameter
Browse files Browse the repository at this point in the history
Resolves #3877.
  • Loading branch information
marcphilipp committed Aug 11, 2024
1 parent 418131f commit c17fc9c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ former, clients can register custom implementations of `{LauncherInterceptor}` v
`junit.platform.launcher.interceptors.enabled` <<running-tests-config-params,
configuration parameter>> to `true`.

[NOTE]
====
Since interceptors are registered before the test run starts, the
`junit.platform.launcher.interceptors.enabled` _configuration parameter_ can only be
supplied as a JVM system property or via the JUnit Platform configuration file (see
<<running-tests-config-params>> for details). This _configuration parameter_ cannot be
supplied in the `LauncherDiscoveryRequest` that is passed to the `{Launcher}`.
====


A typical use case is to create a custom interceptor to replace the `ClassLoader` used by
the JUnit Platform to load test classes and engine implementations.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ public class LauncherConstants {
public static final String STDERR_REPORT_ENTRY_KEY = "stderr";

/**
* Property name used to provide patterns for deactivating listeners registered
* via the {@link java.util.ServiceLoader ServiceLoader} mechanism: {@value}
* Property name used to provide patterns for deactivating
* {@linkplain TestExecutionListener listeners} registered via the
* {@link java.util.ServiceLoader ServiceLoader} mechanism: {@value}
*
* <h4>Pattern Matching Syntax</h4>
*
Expand Down Expand Up @@ -121,6 +122,17 @@ public class LauncherConstants {
* {@code org.example.TheirListener}.
* </ul>
*
* <p>Only listeners registered via the {@code ServiceLoader} mechanism can
* be deactivated. In other words, any listener registered explicitly via the
* {@link LauncherDiscoveryRequest} cannot be deactivated via this
* configuration parameter.
*
* <p>In addition, since execution listeners are registered before the test
* run starts, this configuration parameter can only be supplied as a JVM
* system property or via the JUnit Platform configuration file but cannot
* be supplied in the {@link LauncherDiscoveryRequest}} that is passed to
* the {@link Launcher}.
*
* @see #DEACTIVATE_ALL_LISTENERS_PATTERN
* @see org.junit.platform.launcher.TestExecutionListener
*/
Expand All @@ -143,6 +155,11 @@ public class LauncherConstants {
*
* <p>By default, interceptor registration is disabled.
*
* <p>Since interceptors are registered before the test run starts, this
* configuration parameter can only be supplied as a JVM system property or
* via the JUnit Platform configuration file but cannot be supplied in the
* {@link LauncherDiscoveryRequest}} that is passed to the {@link Launcher}.
*
* @see LauncherInterceptor
*/
@API(status = EXPERIMENTAL, since = "1.10")
Expand Down

0 comments on commit c17fc9c

Please sign in to comment.