Intercepting Invocations
InvocationInterceptor defines the API for Extensions that wish to intercept calls to
test code.
The following example shows an extension that executes all test methods in Swing’s Event Dispatch Thread.
An extension that executes tests in a user-defined thread
public class SwingEdtInterceptor implements InvocationInterceptor {
@Override
public void interceptTestMethod(Invocation<Void> invocation,
ReflectiveInvocationContext<Method> invocationContext,
ExtensionContext extensionContext) throws Throwable {
AtomicReference<Throwable> throwable = new AtomicReference<>();
SwingUtilities.invokeAndWait(() -> {
try {
invocation.proceed();
}
catch (Throwable t) {
throwable.set(t);
}
});
Throwable t = throwable.get();
if (t != null) {
throw t;
}
}
}
|
Accessing the test-scoped
ExtensionContextYou may override the |