Class RepetitionExtension
- java.lang.Object
-
- org.junit.jupiter.engine.extension.RepetitionExtension
-
- All Implemented Interfaces:
ExecutionCondition
,Extension
,ParameterResolver
,TestWatcher
class RepetitionExtension extends java.lang.Object implements ParameterResolver, TestWatcher, ExecutionCondition
RepetitionExtension
implements the following extension APIs to support repetitions of a@RepeatedTest
method.ParameterResolver
to resolveRepetitionInfo
argumentsTestWatcher
to track the failure countExecutionCondition
to disable the repetition if the failure threshold has been exceeded
- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description private DefaultRepetitionInfo
repetitionInfo
-
Constructor Summary
Constructors Constructor Description RepetitionExtension(DefaultRepetitionInfo repetitionInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConditionEvaluationResult
evaluateExecutionCondition(ExtensionContext context)
Evaluate this condition for the suppliedExtensionContext
.RepetitionInfo
resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
Resolve an argument for theParameter
in the suppliedParameterContext
for the suppliedExtensionContext
.boolean
supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
Determine if this resolver supports resolution of an argument for theParameter
in the suppliedParameterContext
for the suppliedExtensionContext
.void
testFailed(ExtensionContext context, java.lang.Throwable cause)
Invoked after a test has failed.-
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.TestWatcher
testAborted, testDisabled, testSuccessful
-
-
-
-
Field Detail
-
repetitionInfo
private final DefaultRepetitionInfo repetitionInfo
-
-
Constructor Detail
-
RepetitionExtension
RepetitionExtension(DefaultRepetitionInfo repetitionInfo)
-
-
Method Detail
-
supportsParameter
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
Description copied from interface:ParameterResolver
Determine if this resolver supports resolution of an argument for theParameter
in the suppliedParameterContext
for the suppliedExtensionContext
.The
Method
orConstructor
in which the parameter is declared can be retrieved viaParameterContext.getDeclaringExecutable()
.- Specified by:
supportsParameter
in interfaceParameterResolver
- Parameters:
parameterContext
- the context for the parameter for which an argument should be resolved; nevernull
extensionContext
- the extension context for theExecutable
about to be invoked; nevernull
- Returns:
true
if this resolver can resolve an argument for the parameter- See Also:
ParameterResolver.resolveParameter(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext)
,ParameterContext
-
resolveParameter
public RepetitionInfo resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
Description copied from interface:ParameterResolver
Resolve an argument for theParameter
in the suppliedParameterContext
for the suppliedExtensionContext
.This method is only called by the framework if
ParameterResolver.supportsParameter(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext)
previously returnedtrue
for the sameParameterContext
andExtensionContext
.The
Method
orConstructor
in which the parameter is declared can be retrieved viaParameterContext.getDeclaringExecutable()
.- Specified by:
resolveParameter
in interfaceParameterResolver
- Parameters:
parameterContext
- the context for the parameter for which an argument should be resolved; nevernull
extensionContext
- the extension context for theExecutable
about to be invoked; nevernull
- Returns:
- the resolved argument for the parameter; may only be
null
if the parameter type is not a primitive - See Also:
ParameterResolver.supportsParameter(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext)
,ParameterContext
-
testFailed
public void testFailed(ExtensionContext context, java.lang.Throwable cause)
Description copied from interface:TestWatcher
Invoked after a test has failed.The default implementation does nothing. Concrete implementations can override this method as appropriate.
- Specified by:
testFailed
in interfaceTestWatcher
- Parameters:
context
- the current extension context; nevernull
cause
- the throwable that caused test failure; may benull
-
evaluateExecutionCondition
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context)
Description copied from interface:ExecutionCondition
Evaluate this condition for the suppliedExtensionContext
.An enabled result indicates that the container or test should be executed; whereas, a disabled result indicates that the container or test should not be executed.
- Specified by:
evaluateExecutionCondition
in interfaceExecutionCondition
- Parameters:
context
- the current extension context; nevernull
- Returns:
- the result of evaluating this condition; never
null
-
-