|
18 | 18 | import org.apiguardian.api.API;
|
19 | 19 |
|
20 | 20 | /**
|
21 |
| - * Interceptor for test discovery and execution by a {@link Launcher}. |
| 21 | + * Interceptor for test discovery and execution by a {@link Launcher} in the |
| 22 | + * context of a {@link LauncherSession}. |
22 | 23 | *
|
23 | 24 | * <p>Interceptors are instantiated once per {@link LauncherSession} and closed
|
24 |
| - * when the session is about to be closed. |
| 25 | + * after the session is closed. They can |
| 26 | + * {@linkplain #intercept(Invocation) intercept} the following invocations: |
| 27 | + * <ul> |
| 28 | + * <li> |
| 29 | + * creation of {@link LauncherSessionListener} instances registered via the |
| 30 | + * {@link java.util.ServiceLoader ServiceLoader} mechanism |
| 31 | + * </li> |
| 32 | + * <li> |
| 33 | + * creation of {@link Launcher} instances |
| 34 | + * </li> |
| 35 | + * <li> |
| 36 | + * calls to {@link Launcher#discover(LauncherDiscoveryRequest)}, |
| 37 | + * {@link Launcher#execute(TestPlan, TestExecutionListener...)}, and |
| 38 | + * {@link Launcher#execute(LauncherDiscoveryRequest, TestExecutionListener...)} |
| 39 | + * </li> |
| 40 | + * </ul> |
| 41 | + * |
| 42 | + * <p>Implementations of this interface can be registered via the |
| 43 | + * {@link java.util.ServiceLoader ServiceLoader} mechanism by additionally |
| 44 | + * setting the {@value LauncherConstants#ENABLE_LAUNCHER_INTERCEPTORS} |
| 45 | + * configuration parameter to {@code true}. |
| 46 | + * |
| 47 | + * <p>A typical use case is to create a custom {@link ClassLoader} in the |
| 48 | + * constructor of the implementing class, replace the |
| 49 | + * {@link Thread#setContextClassLoader(ClassLoader) contextClassLoader} of the |
| 50 | + * current thread while {@link #intercept(Invocation) intercepting} invocations, |
| 51 | + * and close the custom {@code ClassLoader} in {@link #close()} |
25 | 52 | *
|
26 | 53 | * @since 1.10
|
27 | 54 | * @see Launcher
|
|
0 commit comments