Package rife.bld.extension.testing
Class RetryExtension
java.lang.Object
rife.bld.extension.testing.RetryExtension
- All Implemented Interfaces:
Extension
,TestTemplateInvocationContextProvider
JUnit extension that provides retry functionality for failing tests.
This extension implements TestTemplateInvocationContextProvider
to create
multiple invocations of a test method when failures occur.
The extension works by:
- Detecting methods annotated with
@RetryTest
- Creating multiple test invocation contexts
- Tracking failures and successes across invocations
- Stopping retries when a test passes or max retries are reached
Usage: Apply the @RetryTest
annotation to test methods that should be retried on failure.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionProvides invocation contexts for retry attempts.boolean
supportsTestTemplate
(ExtensionContext context) Determines if this extension supports the given test context.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider
mayReturnZeroTestTemplateInvocationContexts
-
Constructor Details
-
RetryExtension
public RetryExtension()
-
-
Method Details
-
supportsTestTemplate
Determines if this extension supports the given test context.Returns
true
if the test method is annotated with@RetryTest
.- Specified by:
supportsTestTemplate
in interfaceTestTemplateInvocationContextProvider
- Parameters:
context
- the extension context for the test- Returns:
true
if the test method is annotated with@RetryTest
,false
otherwise
-
provideTestTemplateInvocationContexts
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) Provides invocation contexts for retry attempts.Creates a stream of invocation contexts based on the retry count specified in the
@RetryTest
annotation.- Specified by:
provideTestTemplateInvocationContexts
in interfaceTestTemplateInvocationContextProvider
- Parameters:
context
- the extension context for the test- Returns:
- a stream of
TestTemplateInvocationContext
for each retry attempt
-