Package groovy.junit6.plugin
Class ForkedJvmExtension
java.lang.Object
groovy.junit6.plugin.ForkedJvmExtension
- All Implemented Interfaces:
Extension,InvocationInterceptor,TestInstantiationAwareExtension
JUnit 5
InvocationInterceptor backing the ForkedJvm
annotation. When applied, the test method is skipped in the current JVM and
re-run in a freshly forked JVM via ForkedJvmTestRunner, with any
declared system properties and JVM args.
Recursion is avoided by setting the system property
ForkedJvmTestRunner.FORKED_FLAG on the child; when the extension
sees that flag set in the current JVM it just proceeds with the normal
invocation (i.e. the child JVM actually runs the test body).
- 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 naming a comma-separated list of regular expressions to exclude from the parent'sjava.class.pathwhen building the forked JVM's classpath. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringfilterClasspath(String classpath, List<Pattern> excludes) Filtersclasspath(aFile.pathSeparator-separated list) by dropping entries that match any of the supplied regular expressions viaMatcher.find().voidinterceptTestMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) 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
-
EXCLUDE_CLASSPATH_PROP
System property naming a comma-separated list of regular expressions to exclude from the parent'sjava.class.pathwhen building the forked JVM's classpath. AugmentsForkedJvm.excludeFromClasspath().- See Also:
-
-
Constructor Details
-
ForkedJvmExtension
public ForkedJvmExtension()
-
-
Method Details
-
interceptTestMethod
public void interceptTestMethod(InvocationInterceptor.Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable - Specified by:
interceptTestMethodin interfaceInvocationInterceptor- Throws:
Throwable
-
filterClasspath
Filtersclasspath(aFile.pathSeparator-separated list) by dropping entries that match any of the supplied regular expressions viaMatcher.find(). Visible for testing.- Parameters:
classpath- the original classpath stringexcludes- regex patterns; an empty list returnsclasspathunchanged- Returns:
- the filtered classpath string
-