Package groovy.junit6.plugin
Class ExpectedToFailExtension
java.lang.Object
groovy.junit6.plugin.ExpectedToFailExtension
- All Implemented Interfaces:
Extension,InvocationInterceptor,TestInstantiationAwareExtension
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.
- Since:
- 6.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
InvocationInterceptor.Invocation<T extends Object>Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
TestInstantiationAwareExtension.ExtensionContextScope -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property set on the child JVM's command line byForkedJvmExtensionwhen the parent's@ExpectedToFailhas claimed the inversion. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinterceptTestMethod(InvocationInterceptor.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
interceptAfterAllMethod, interceptAfterEachMethod, interceptBeforeAllMethod, interceptBeforeEachMethod, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod, interceptTestTemplateMethodMethods inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
getTestInstantiationExtensionContextScope
-
Field Details
-
DEFERRED_TO_PARENT_PROP
System property set on the child JVM's command line byForkedJvmExtensionwhen the parent's@ExpectedToFailhas claimed the inversion. The child's@ExpectedToFailinterceptor checks this property and passes through honestly so the parent can observe the propagated outcome.- See Also:
-
-
Constructor Details
-
ExpectedToFailExtension
public ExpectedToFailExtension()
-
-
Method Details
-
interceptTestMethod
public void interceptTestMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable 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. ATestAbortedExceptionis 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.- Specified by:
interceptTestMethodin interfaceInvocationInterceptor- Throws:
Throwable
-