Interface Failure

All Known Subinterfaces:
FileComparisonTestAssertionFailure, TestAssertionFailure, TestFailure, TestFrameworkFailure

public interface Failure
Represents a failure. Failures are similar to exceptions but carry less information (only a message, a description and a cause) so they can be used in a wider scope than just the JVM where the exception failed.
Since:
2.4
  • Method Summary

    Modifier and Type
    Method
    Description
    List<? extends Failure>
    Returns the underlying causes for this failure, if any.
    @Nullable String
    Returns a long description of the failure.
    @Nullable String
    Returns a short message (typically one line) for the failure.
    @Nullable String
    Returns a long description of this failure node, excluding the descriptions of its causes.
    Returns the problems associated with this failure.
  • Method Details

    • getMessage

      @Nullable String getMessage()
      Returns a short message (typically one line) for the failure.
      Returns:
      the failure message
      Since:
      2.4
    • getDescription

      @Nullable String getDescription()
      Returns a long description of the failure. For example, a stack trace. Call this method on the root failure only: the description may include the full text of the failures returned by getCauses(). When inspecting every node in a failure tree, use getOwnDescription() to avoid processing cause descriptions repeatedly.
      Returns:
      a long description of the failure
      Since:
      2.4
    • getOwnDescription

      @Incubating @Nullable String getOwnDescription()
      Returns a long description of this failure node, excluding the descriptions of its causes. For example, the failure header, its stack frames, and any suppressed exceptions, but not the descriptions of the failures returned by getCauses().

      Unlike getDescription(), which may contain the text of the whole cause subtree, this method can be used to inspect the description of every node in a failure tree without processing cause descriptions repeatedly.

      When using a target Gradle version earlier than 9.7.0, this method returns null.

      Returns:
      a long description of this failure node, or null if it is not available
      Since:
      9.8.0
    • getCauses

      List<? extends Failure> getCauses()
      Returns the underlying causes for this failure, if any.
      Returns:
      the causes for this failure. Returns an empty list if this failure has no causes.
      Since:
      2.4
    • getProblems

      @Incubating List<Problem> getProblems()
      Returns the problems associated with this failure.
      Returns:
      The problems, or an empty list if there are no problems.
      Since:
      8.12