Top Description Inners Methods
org.junit.platform.launcher

public Interface LauncherInterceptor

Known Direct Implementers
org.junit.platform.launcher.core.ClasspathAlignmentCheckingLauncherInterceptor
Annotations
@API
status:MAINTAINED
since:1.13.3
Static Imports
org.apiguardian.api.API.Status.MAINTAINED

Interceptor for test discovery and execution by a Launcher in the context of a LauncherSession.

Interceptors are instantiated once per LauncherSession and closed after the session is closed. They can intercept the following invocations:

Implementations of this interface can be registered via the ServiceLoader mechanism by additionally setting the junit.platform.launcher.interceptors.enabled configuration parameter to true.

A typical use case is to create a custom ClassLoader in the constructor of the implementing class, replace the contextClassLoader of the current thread while intercepting invocations, and close the custom ClassLoader in close()

Since
1.10
See Also
Launcher, LauncherSession, LauncherConstants#ENABLE_LAUNCHER_INTERCEPTORS

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
LauncherInterceptor.Invocation<T extends @Nullable Object>

An invocation that can be intercepted.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Closes this interceptor.

public <T extends @Nullable Object> T

Returns:

the result of the invocation
intercept
(LauncherInterceptor.Invocation<T>
the intercepted invocation; never null
invocation
)

Intercept the supplied invocation.

Method Detail

closeback to summary
public void close()

Closes this interceptor.

Any resources held by this interceptor should be released by this method.

interceptback to summary
public <T extends @Nullable Object> T intercept(LauncherInterceptor.Invocation<T> invocation)

Intercept the supplied invocation.

Implementations must call Invocation#proceed() exactly once.

Parameters
invocation:LauncherInterceptor.Invocation<T>

the intercepted invocation; never null

Returns:T

the result of the invocation

org.junit.platform.launcher back to summary

public Interface LauncherInterceptor.Invocation<T extends @Nullable Object>


An invocation that can be intercepted.

This interface is not intended to be implemented by clients.

Method Summary

Modifier and TypeMethod and Description
public T

Method Detail

proceedback to summary
public T proceed()