Package spock.lang

Annotation Type FailsWith


  • @Retention(RUNTIME)
    @Target({METHOD,TYPE})
    public @interface FailsWith
    Indicates that a feature method is expected to fail with the given exception. Useful for pinpointing bugs until they get fixed, or as a replacement for exception conditions in certain corner cases where they cannot be used (like specifying the behavior of exception conditions). In all other cases, exception conditions are preferable.

    Applying this annotation to a specification has the same effect as applying it to all feature methods that aren't already annotated with @FailsWith.

    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      Class<? extends Throwable> value
      The expected exception type.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String reason
      The reason for the failure.
    • Element Detail

      • value

        Class<? extends Throwable> value
        The expected exception type.
        Returns:
        the expected exception type
      • reason

        String reason
        The reason for the failure.
        Returns:
        the reason for the failure
        Default:
        "unknown"