Class EnabledIfCondition
java.lang.Object
org.springframework.test.context.junit.jupiter.EnabledIfCondition
- All Implemented Interfaces:
ExecutionCondition
,Extension
EnabledIfCondition
is an ExecutionCondition
that supports the @EnabledIf
annotation when using the Spring
TestContext Framework in conjunction with JUnit 5's Jupiter programming model.
Any attempt to use the EnabledIfCondition
without the presence of
@EnabledIf
will result in an enabled
ConditionEvaluationResult
.
- Since:
- 5.0
- Author:
- Sam Brannen
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <A extends Annotation>
ConditionEvaluationResultevaluateAnnotation
(Class<A> annotationType, Function<A, String> expressionExtractor, Function<A, String> reasonExtractor, Function<A, Boolean> loadContextExtractor, boolean enabledOnTrue, ExtensionContext context) Evaluate the expression configured via the supplied annotation type on theAnnotatedElement
for the suppliedExtensionContext
.Containers and tests are enabled if@EnabledIf
is present on the corresponding test class or test method and the configured expression evaluates totrue
.
-
Constructor Details
-
EnabledIfCondition
public EnabledIfCondition()
-
-
Method Details
-
evaluateExecutionCondition
Containers and tests are enabled if@EnabledIf
is present on the corresponding test class or test method and the configured expression evaluates totrue
. -
evaluateAnnotation
protected <A extends Annotation> ConditionEvaluationResult evaluateAnnotation(Class<A> annotationType, Function<A, String> expressionExtractor, Function<A, String> reasonExtractor, Function<A, Boolean> loadContextExtractor, boolean enabledOnTrue, ExtensionContext context) Evaluate the expression configured via the supplied annotation type on theAnnotatedElement
for the suppliedExtensionContext
.- Parameters:
annotationType
- the type of annotation to processexpressionExtractor
- a function that extracts the expression from the annotationreasonExtractor
- a function that extracts the reason from the annotationloadContextExtractor
- a function that extracts theloadContext
flag from the annotationenabledOnTrue
- indicates whether the returnedConditionEvaluationResult
should beenabled
if the expression evaluates totrue
context
- theExtensionContext
- Returns:
enabled
if the container or test should be enabled; otherwisedisabled
-