org.springframework.test.context.junit.jupiter

Class DisabledIfCondition

  • java.lang.Object
    • org.springframework.test.context.junit.jupiter.DisabledIfCondition
  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.ExecutionCondition, org.junit.jupiter.api.extension.Extension


    public class DisabledIfCondition
    extends java.lang.Object
    DisabledIfCondition is an ExecutionCondition that supports the @DisabledIf annotation when using the Spring TestContext Framework in conjunction with JUnit 5's Jupiter programming model.

    Any attempt to use the DisabledIfCondition without the presence of @DisabledIf will result in an enabled ConditionEvaluationResult.

    Since:
    5.0
    Author:
    Sam Brannen
    See Also:
    DisabledIf, EnabledIf, SpringExtension
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      protected <A extends java.lang.annotation.Annotation>
      org.junit.jupiter.api.extension.ConditionEvaluationResult
      evaluateAnnotation(java.lang.Class<A> annotationType, java.util.function.Function<A,java.lang.String> expressionExtractor, java.util.function.Function<A,java.lang.String> reasonExtractor, java.util.function.Function<A,java.lang.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.
      org.junit.jupiter.api.extension.ConditionEvaluationResult evaluateExecutionCondition(org.junit.jupiter.api.extension.ExtensionContext context)
      Containers and tests are disabled if @DisabledIf is present on the corresponding test class or test method and the configured expression evaluates to true.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DisabledIfCondition

        public DisabledIfCondition()
    • Method Detail

      • evaluateExecutionCondition

        public org.junit.jupiter.api.extension.ConditionEvaluationResult evaluateExecutionCondition(org.junit.jupiter.api.extension.ExtensionContext context)
        Containers and tests are disabled if @DisabledIf is present on the corresponding test class or test method and the configured expression evaluates to true.
      • evaluateAnnotation

        protected <A extends java.lang.annotation.Annotation> org.junit.jupiter.api.extension.ConditionEvaluationResult evaluateAnnotation(java.lang.Class<A> annotationType,
                                                                                                                                           java.util.function.Function<A,java.lang.String> expressionExtractor,
                                                                                                                                           java.util.function.Function<A,java.lang.String> reasonExtractor,
                                                                                                                                           java.util.function.Function<A,java.lang.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.
        Parameters:
        annotationType - the type of annotation to process
        expressionExtractor - a function that extracts the expression from the annotation
        reasonExtractor - a function that extracts the reason from the annotation
        loadContextExtractor - a function that extracts the loadContext flag from the annotation
        enabledOnTrue - indicates whether the returned ConditionEvaluationResult should be enabled if the expression evaluates to true
        context - the ExtensionContext
        Returns:
        enabled if the container or test should be enabled; otherwise disabled