Class RepeatIfExceptionsExtension

  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.TestExecutionExceptionHandler, org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider

    public class RepeatIfExceptionsExtension
    extends Object
    implements org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.TestExecutionExceptionHandler
    Main condition for extension point @RepeatedIfExceptions All logic in this class. See TestTemplateIterator where handler logic of repeat tests
    Author:
    Artem Sokovets
    • Constructor Detail

      • RepeatIfExceptionsExtension

        public RepeatIfExceptionsExtension()
    • Method Detail

      • supportsTestTemplate

        public boolean supportsTestTemplate​(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
        Check that test method contain RepeatedIfExceptionsTest annotation
        Specified by:
        supportsTestTemplate in interface org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
        Parameters:
        extensionContext - - encapsulates the context in which the current test or container is being executed
        Returns:
        true/false
      • provideTestTemplateInvocationContexts

        public Stream<org.junit.jupiter.api.extension.TestTemplateInvocationContext> provideTestTemplateInvocationContexts​(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
        Context call TestTemplateInvocationContext
        Specified by:
        provideTestTemplateInvocationContexts in interface org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
        Parameters:
        extensionContext - - Test Class Context
        Returns:
        Stream of TestTemplateInvocationContext
      • beforeTestExecution

        public void beforeTestExecution​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        beforeTestExecution in interface org.junit.jupiter.api.extension.BeforeTestExecutionCallback
      • afterTestExecution

        public void afterTestExecution​(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
        Check if exceptions that will appear in test same as we wait
        Specified by:
        afterTestExecution in interface org.junit.jupiter.api.extension.AfterTestExecutionCallback
        Parameters:
        extensionContext - - Test Class Context
      • handleTestExecutionException

        public void handleTestExecutionException​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                 Throwable throwable)
                                          throws Throwable
        Specified by:
        handleTestExecutionException in interface org.junit.jupiter.api.extension.TestExecutionExceptionHandler
        Throws:
        Throwable