Class TimeoutExtension

java.lang.Object
org.junitpioneer.vintage.TimeoutExtension
All Implemented Interfaces:
org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.InvocationInterceptor

class TimeoutExtension extends Object implements org.junit.jupiter.api.extension.InvocationInterceptor
This extension implements the timeout behavior of @Test, where a test is failed if it takes longer to finish than the specified time.

Note that this is different from JUnit 4's @Test parameter, which would abandon the test if it ran to long and continue with the remainder of the suite. As Jupiter's extension API is currently not powerful enough to interact with its threading model, this could not be implemented.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor

    org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private Optional<Long>
    annotatedTimeout(org.junit.jupiter.api.extension.ExtensionContext context)
     
    void
    interceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
     
    private void
    proceedWithTimeout(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ExtensionContext extensionContext, long timeout)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor

    interceptAfterAllMethod, interceptAfterEachMethod, interceptBeforeAllMethod, interceptBeforeEachMethod, interceptDynamicTest, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod, interceptTestTemplateMethod
  • Field Details

  • Constructor Details

    • TimeoutExtension

      TimeoutExtension()
  • Method Details

    • interceptTestMethod

      public void interceptTestMethod(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:
      interceptTestMethod in interface org.junit.jupiter.api.extension.InvocationInterceptor
      Throws:
      Throwable
    • proceedWithTimeout

      private void proceedWithTimeout(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ExtensionContext extensionContext, long timeout)
    • annotatedTimeout

      private Optional<Long> annotatedTimeout(org.junit.jupiter.api.extension.ExtensionContext context)