org.springframework.test.context.junit4.statements

Class ProfileValueChecker

  • java.lang.Object
    • org.junit.runners.model.Statement
      • org.springframework.test.context.junit4.statements.ProfileValueChecker


  • public class ProfileValueChecker
    extends org.junit.runners.model.Statement
    ProfileValueChecker is a custom JUnit Statement that checks whether a test class or test method is enabled in the current environment via Spring's @IfProfileValue annotation.
    Since:
    4.2
    Author:
    Sam Brannen, Philippe Marschall
    See Also:
    evaluate(), IfProfileValue, ProfileValueUtils
    • Constructor Summary

      Constructors 
      Constructor and Description
      ProfileValueChecker(org.junit.runners.model.Statement next, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)
      Construct a new ProfileValueChecker statement.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void evaluate()
      Determine if the test specified by arguments to the constructor is enabled in the current environment, as configured via the @IfProfileValue annotation.
      • Methods inherited from class java.lang.Object

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

      • ProfileValueChecker

        public ProfileValueChecker(org.junit.runners.model.Statement next,
                                   java.lang.Class<?> testClass,
                                   @Nullable
                                   java.lang.reflect.Method testMethod)
        Construct a new ProfileValueChecker statement.
        Parameters:
        next - the next Statement in the execution chain; never null
        testClass - the test class to check; never null
        testMethod - the test method to check; may be null if this ProfileValueChecker is being applied at the class level
    • Method Detail

      • evaluate

        public void evaluate()
                      throws java.lang.Throwable
        Determine if the test specified by arguments to the constructor is enabled in the current environment, as configured via the @IfProfileValue annotation.

        If the test is not annotated with @IfProfileValue it is considered enabled.

        If a test is not enabled, this method will abort further evaluation of the execution chain with a failed assumption; otherwise, this method will simply evaluate the next Statement in the execution chain.

        Specified by:
        evaluate in class org.junit.runners.model.Statement
        Throws:
        org.junit.AssumptionViolatedException - if the test is disabled
        java.lang.Throwable - if evaluation of the next statement fails
        See Also:
        ProfileValueUtils.isTestEnabledInThisEnvironment(Class), ProfileValueUtils.isTestEnabledInThisEnvironment(Method, Class)