Package se.deversity.asynctest.extension
Class AsyncTestInvocationInterceptor
java.lang.Object
se.deversity.asynctest.extension.AsyncTestInvocationInterceptor
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.InvocationInterceptor,org.junit.jupiter.api.extension.TestInstantiationAwareExtension
@API(status=STABLE)
public class AsyncTestInvocationInterceptor
extends Object
implements org.junit.jupiter.api.extension.InvocationInterceptor, org.junit.jupiter.api.extension.AfterEachCallback
Intercepts the execution of the test method and delegates it to the
ConcurrencyRunner.
This interceptor skips the default JUnit invocation and instead runs the test body concurrently across multiple threads to maximize the chance of detecting race conditions.
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T>Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
org.junit.jupiter.api.extension.TestInstantiationAwareExtension.ExtensionContextScope -
Constructor Summary
ConstructorsConstructorDescriptionAsyncTestInvocationInterceptor(AsyncTest asyncTest) Creates a AsyncTestInvocationInterceptor.AsyncTestInvocationInterceptor(AsyncTest asyncTest, int threadCount) Construct with an explicit thread count, used by the schedule-matrix path in@AsyncTest(threadCounts=...)where each matrix entry runs with its own count. -
Method Summary
Modifier and TypeMethodDescriptionvoidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) Reports the executors the run declared that the test's own@AfterEachmethods did not shut down either.voidinterceptTestTemplateMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.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, interceptTestMethodMethods inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
getTestInstantiationExtensionContextScope
-
Constructor Details
-
AsyncTestInvocationInterceptor
Creates a AsyncTestInvocationInterceptor.- Parameters:
asyncTest- the annotation on the test method, supplying the run configuration
-
AsyncTestInvocationInterceptor
Construct with an explicit thread count, used by the schedule-matrix path in@AsyncTest(threadCounts=...)where each matrix entry runs with its own count.- Parameters:
asyncTest- the annotation on the test method, supplying the run configurationthreadCount- thread count to use instead of the annotation value, for a parameterised template- Since:
- 1.6.0
-
-
Method Details
-
interceptTestTemplateMethod
public void interceptTestTemplateMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptTestTemplateMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) Reports the executors the run declared that the test's own@AfterEachmethods did not shut down either. JUnit calls an extension'safterEachafter those methods, and the run's analysis came before them, so a pool closed in teardown is judged here (#996).- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Parameters:
context- the invocation's extension context- Since:
- 1.13.2
-