Class ExtensionLifecycleMerger
- java.lang.Object
-
- org.spockframework.runtime.extension.AbstractMethodInterceptor
-
- ru.vyarus.spock.jupiter.interceptor.ExtensionLifecycleMerger
-
- All Implemented Interfaces:
org.spockframework.runtime.extension.IMethodInterceptor
public class ExtensionLifecycleMerger extends org.spockframework.runtime.extension.AbstractMethodInterceptorMerges junit extensions lifecycle into spock. Junit extensions executed before any other spock extensions (only other global spock extensions may be executed before, but they are almost never used).Implementation based on
org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptorandorg.junit.jupiter.engine.descriptor.TestMethodTestDescriptorfrom junit-jupiter-engine.NOTE: spock
@Sharedfields could not be supported as it would require duplicate beforeEach execution with different instances, which would probably break many junit extensions. As a result,@Sharedfields would ALWAYS be null (because they are managed in a different instance - extension would not be able to initialize it in any case). This would produce ambiguous situations I can't detect. And so there is only one rule: nothing junit-specific should use@Sharedannotation.- Since:
- 30.11.2021
-
-
Constructor Summary
Constructors Constructor Description ExtensionLifecycleMerger(ClassContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.spockframework.runtime.extension.IMethodInterceptorgetFixtureMethodsInterceptor()Interceptor externalized in order to unify all interceptor registration in one place.MethodContextgetMethodContext(org.spockframework.runtime.extension.IMethodInvocation invocation)ClassContextgetSpecContext()voidinterceptCleanupMethod(org.spockframework.runtime.extension.IMethodInvocation invocation)voidinterceptCleanupSpecMethod(org.spockframework.runtime.extension.IMethodInvocation invocation)voidinterceptFeatureMethod(org.spockframework.runtime.extension.IMethodInvocation invocation)voidinterceptInitializerMethod(org.spockframework.runtime.extension.IMethodInvocation invocation)voidinterceptSetupMethod(org.spockframework.runtime.extension.IMethodInvocation invocation)voidinterceptSetupSpecMethod(org.spockframework.runtime.extension.IMethodInvocation invocation)
-
-
-
Constructor Detail
-
ExtensionLifecycleMerger
public ExtensionLifecycleMerger(ClassContext context)
-
-
Method Detail
-
getFixtureMethodsInterceptor
public org.spockframework.runtime.extension.IMethodInterceptor getFixtureMethodsInterceptor()
Interceptor externalized in order to unify all interceptor registration in one place.- Returns:
- interceptor for fixture methods (setup/cleanup)
-
getSpecContext
public ClassContext getSpecContext()
- Returns:
- spec-level context
-
getMethodContext
public MethodContext getMethodContext(org.spockframework.runtime.extension.IMethodInvocation invocation)
- Parameters:
invocation- spock event- Returns:
- method context
- Throws:
java.lang.NullPointerException- when context not found
-
interceptSetupSpecMethod
public void interceptSetupSpecMethod(org.spockframework.runtime.extension.IMethodInvocation invocation) throws java.lang.Throwable- Overrides:
interceptSetupSpecMethodin classorg.spockframework.runtime.extension.AbstractMethodInterceptor- Throws:
java.lang.Throwable
-
interceptInitializerMethod
public void interceptInitializerMethod(org.spockframework.runtime.extension.IMethodInvocation invocation) throws java.lang.Throwable- Overrides:
interceptInitializerMethodin classorg.spockframework.runtime.extension.AbstractMethodInterceptor- Throws:
java.lang.Throwable
-
interceptSetupMethod
public void interceptSetupMethod(org.spockframework.runtime.extension.IMethodInvocation invocation) throws java.lang.Throwable- Overrides:
interceptSetupMethodin classorg.spockframework.runtime.extension.AbstractMethodInterceptor- Throws:
java.lang.Throwable
-
interceptFeatureMethod
public void interceptFeatureMethod(org.spockframework.runtime.extension.IMethodInvocation invocation) throws java.lang.Throwable- Overrides:
interceptFeatureMethodin classorg.spockframework.runtime.extension.AbstractMethodInterceptor- Throws:
java.lang.Throwable
-
interceptCleanupMethod
public void interceptCleanupMethod(org.spockframework.runtime.extension.IMethodInvocation invocation) throws java.lang.Throwable- Overrides:
interceptCleanupMethodin classorg.spockframework.runtime.extension.AbstractMethodInterceptor- Throws:
java.lang.Throwable
-
interceptCleanupSpecMethod
public void interceptCleanupSpecMethod(org.spockframework.runtime.extension.IMethodInvocation invocation) throws java.lang.Throwable- Overrides:
interceptCleanupSpecMethodin classorg.spockframework.runtime.extension.AbstractMethodInterceptor- Throws:
java.lang.Throwable
-
-