public class EnabledIfCondition extends Object
EnabledIfCondition is a composite ContainerExecutionCondition
and TestExecutionCondition 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.
EnabledIf,
DisabledIf,
SpringExtension| Constructor and Description |
|---|
EnabledIfCondition() |
| Modifier and Type | Method and Description |
|---|---|
org.junit.jupiter.api.extension.ConditionEvaluationResult |
evaluate(org.junit.jupiter.api.extension.ContainerExtensionContext context)
Containers are enabled if
@EnabledIf is present on the test class
and the configured expression evaluates to true. |
org.junit.jupiter.api.extension.ConditionEvaluationResult |
evaluate(org.junit.jupiter.api.extension.TestExtensionContext context)
Tests are enabled if
@EnabledIf is present on the test method
and the configured expression evaluates to true. |
protected <A extends Annotation> |
evaluateAnnotation(Class<A> annotationType,
Function<A,String> expressionExtractor,
Function<A,String> reasonExtractor,
Function<A,Boolean> loadContextExtractor,
boolean enabledOnTrue,
org.junit.jupiter.api.extension.ExtensionContext context)
Evaluate the expression configured via the supplied annotation type on
the
AnnotatedElement for the supplied ExtensionContext. |
public org.junit.jupiter.api.extension.ConditionEvaluationResult evaluate(org.junit.jupiter.api.extension.ContainerExtensionContext context)
@EnabledIf is present on the test class
and the configured expression evaluates to true.public org.junit.jupiter.api.extension.ConditionEvaluationResult evaluate(org.junit.jupiter.api.extension.TestExtensionContext context)
@EnabledIf is present on the test method
and the configured expression evaluates to true.protected <A extends Annotation> org.junit.jupiter.api.extension.ConditionEvaluationResult evaluateAnnotation(Class<A> annotationType, Function<A,String> expressionExtractor, Function<A,String> reasonExtractor, Function<A,Boolean> loadContextExtractor, boolean enabledOnTrue, org.junit.jupiter.api.extension.ExtensionContext context)
AnnotatedElement for the supplied ExtensionContext.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 the loadContext
flag from the annotationenabledOnTrue - indicates whether the returned ConditionEvaluationResult
should be enabled if the expression
evaluates to truecontext - the ExtensionContextenabled if the container
or test should be enabled; otherwise disabled