Class DisabledIfCondition
- java.lang.Object
- org.springframework.test.context.junit.jupiter.DisabledIfCondition
- All Implemented Interfaces:
ExecutionCondition,Extension
public class DisabledIfCondition extends Object
DisabledIfConditionis anExecutionConditionthat supports the@DisabledIfannotation when using the Spring TestContext Framework in conjunction with JUnit 5's Jupiter programming model.Any attempt to use the
DisabledIfConditionwithout the presence of@DisabledIfwill result in an enabledConditionEvaluationResult.- Since:
- 5.0
- Author:
- Sam Brannen
- See Also:
DisabledIf,EnabledIf,SpringExtension
Constructor Summary
Constructors Constructor Description DisabledIfCondition()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <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 theAnnotatedElementfor the suppliedExtensionContext.ConditionEvaluationResultevaluateExecutionCondition(ExtensionContext context)Containers and tests are disabled if@DisabledIfis present on the corresponding test class or test method and the configured expression evaluates totrue.
Constructor Detail
DisabledIfCondition
public DisabledIfCondition()
Method Detail
evaluateExecutionCondition
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context)
Containers and tests are disabled if@DisabledIfis 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 theAnnotatedElementfor 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 theloadContextflag from the annotationenabledOnTrue- indicates whether the returnedConditionEvaluationResultshould beenabledif the expression evaluates totruecontext- theExtensionContext- Returns:
enabledif the container or test should be enabled; otherwisedisabled