Package spock.lang

Annotation Type IgnoreIf


  • @Retention(RUNTIME)
    @Target({TYPE,METHOD})
    @Repeatable(Container.class)
    public @interface IgnoreIf
    Ignores the annotated spec, feature or selected iterations if the given condition holds. Same as Requires except that the condition is inverted.

    The configured closure is called with a delegate of type PreconditionContext which provides access to system properties, environment variables, the type of operating system and JVM.

    If applied to a data driven feature, the closure can also access the data variables. If the closure does not reference any actual data variables or is applied to a spec, the whole annotated element is skipped up-front, no fixtures, data providers or anything else will be executed. But if the closure actually does reference valid data variables, the whole workflow is followed up to the feature method invocation, where then the closure is checked, and it is decided whether to abort the specific iteration or not.

    See Also:
    Requires, PreconditionContext
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      Class<? extends Closure> value
      The condition to check, PreconditionContext will be set as delegate and argument.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean inherited
      Whether this annotation should be inherited by child classes.
      String reason
      The reason for ignoring this element.
    • Element Detail

      • value

        Class<? extends Closure> value
        The condition to check, PreconditionContext will be set as delegate and argument.
        Returns:
        the closure to evaluate
      • reason

        String reason
        The reason for ignoring this element.
        Returns:
        the string to use for the skip message
        Default:
        ""
      • inherited

        boolean inherited
        Whether this annotation should be inherited by child classes. For historic reasons, this is false by default. It has no special effect if used on a feature.
        Returns:
        whether this annotation applies to child classes
        Since:
        2.1
        Default:
        false