Skip to content

Commit c17fc9c

Browse files
committed
Document limitations of interceptor enabling configuration parameter
Resolves #3877.
1 parent 418131f commit c17fc9c

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

documentation/src/docs/asciidoc/user-guide/advanced-topics/launcher-api.adoc

+10
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ former, clients can register custom implementations of `{LauncherInterceptor}` v
173173
`junit.platform.launcher.interceptors.enabled` <<running-tests-config-params,
174174
configuration parameter>> to `true`.
175175

176+
[NOTE]
177+
====
178+
Since interceptors are registered before the test run starts, the
179+
`junit.platform.launcher.interceptors.enabled` _configuration parameter_ can only be
180+
supplied as a JVM system property or via the JUnit Platform configuration file (see
181+
<<running-tests-config-params>> for details). This _configuration parameter_ cannot be
182+
supplied in the `LauncherDiscoveryRequest` that is passed to the `{Launcher}`.
183+
====
184+
185+
176186
A typical use case is to create a custom interceptor to replace the `ClassLoader` used by
177187
the JUnit Platform to load test classes and engine implementations.
178188

junit-platform-launcher/src/main/java/org/junit/platform/launcher/LauncherConstants.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ public class LauncherConstants {
9292
public static final String STDERR_REPORT_ENTRY_KEY = "stderr";
9393

9494
/**
95-
* Property name used to provide patterns for deactivating listeners registered
96-
* via the {@link java.util.ServiceLoader ServiceLoader} mechanism: {@value}
95+
* Property name used to provide patterns for deactivating
96+
* {@linkplain TestExecutionListener listeners} registered via the
97+
* {@link java.util.ServiceLoader ServiceLoader} mechanism: {@value}
9798
*
9899
* <h4>Pattern Matching Syntax</h4>
99100
*
@@ -121,6 +122,17 @@ public class LauncherConstants {
121122
* {@code org.example.TheirListener}.
122123
* </ul>
123124
*
125+
* <p>Only listeners registered via the {@code ServiceLoader} mechanism can
126+
* be deactivated. In other words, any listener registered explicitly via the
127+
* {@link LauncherDiscoveryRequest} cannot be deactivated via this
128+
* configuration parameter.
129+
*
130+
* <p>In addition, since execution listeners are registered before the test
131+
* run starts, this configuration parameter can only be supplied as a JVM
132+
* system property or via the JUnit Platform configuration file but cannot
133+
* be supplied in the {@link LauncherDiscoveryRequest}} that is passed to
134+
* the {@link Launcher}.
135+
*
124136
* @see #DEACTIVATE_ALL_LISTENERS_PATTERN
125137
* @see org.junit.platform.launcher.TestExecutionListener
126138
*/
@@ -143,6 +155,11 @@ public class LauncherConstants {
143155
*
144156
* <p>By default, interceptor registration is disabled.
145157
*
158+
* <p>Since interceptors are registered before the test run starts, this
159+
* configuration parameter can only be supplied as a JVM system property or
160+
* via the JUnit Platform configuration file but cannot be supplied in the
161+
* {@link LauncherDiscoveryRequest}} that is passed to the {@link Launcher}.
162+
*
146163
* @see LauncherInterceptor
147164
*/
148165
@API(status = EXPERIMENTAL, since = "1.10")

0 commit comments

Comments
 (0)