public class ExpectedToFailExtension
extends Object
implements InvocationInterceptor
JUnit 5 InvocationInterceptor backing the ExpectedToFail annotation. Inverts a test's pass/fail outcome with optional exception-type and message-substring filters.
Composes with ForkedJvm in either declaration order via explicit coordination through ExtensionContext.Store and a child-JVM system property — not via brittle reliance on annotation iteration order.
| Modifiers | Name | Description |
|---|---|---|
static String |
DEFERRED_TO_PARENT_PROP |
System property set on the child JVM's command line by
ForkedJvmExtension when the parent's @ExpectedToFail
has claimed the inversion. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext)Runs the test and inverts its outcome when ExpectedToFail applies to the method or the test class. |
System property set on the child JVM's command line by
ForkedJvmExtension when the parent's @ExpectedToFail
has claimed the inversion. The child's @ExpectedToFail
interceptor checks this property and passes through honestly so the
parent can observe the propagated outcome.
Runs the test and inverts its outcome when ExpectedToFail applies to the method or the test class. A missing annotation, or the child-JVM deferral property, proceeds without inversion. In the parent JVM, a ForkedJvm annotation on the method or class records that this interceptor will invert so the child does not. A org.opentest4j.TestAbortedException is rethrown. Any other throwable, or a normal return, is checked against the annotation's type, exception, and closure predicate: a match is swallowed and a pass or a mismatch becomes an assertion error.