TestFailure (Gradle API 7.6.3)

Package org.gradle.api.tasks.testing

## Class TestFailure

- java.lang.Object
- - org.gradle.api.tasks.testing.TestFailure

-     @Incubating
      public abstract class TestFailure
      extends java.lang.Object

  Describes a test failure. Contains a reference to the failure and some structural information retrieved by the test worker.
  Since:
    7.6

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TestFailure()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static TestFailure` | `fromTestAssertionFailure​(java.lang.Throwable failure, java.lang.String expected, java.lang.String actual)` | Creates a new TestFailure instance from an assertion failure.
    `static TestFailure` | `fromTestAssertionFailure​(java.lang.Throwable failure, java.lang.String expected, java.lang.String actual, java.util.List<TestFailure> causes)` | Creates a new TestFailure instance from an assertion failure.
    `static TestFailure` | `fromTestFrameworkFailure​(java.lang.Throwable failure)` | Creates a new TestFailure instance from a test framework failure.
    `static TestFailure` | `fromTestFrameworkFailure​(java.lang.Throwable failure, java.util.List<TestFailure> causes)` | Creates a new TestFailure instance from a test framework failure.
    `abstract java.util.List<TestFailure>` | `getCauses()` | Returns the list of causes.
    `abstract TestFailureDetails` | `getDetails()` | Returns structural information about the failure.
    `abstract java.lang.Throwable` | `getRawFailure()` | Returns the raw failure.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TestFailure

          public TestFailure()

  - ### Method Detail

    - #### getCauses

          public abstract java.util.List<TestFailure> getCauses()

      Returns the list of causes.

      The result is typically non-empty for multi-assertion failures, e.g. for `org.test4j.MultipleFailuresError`, where the individual failures are in the returned list.

      Returns:
        the cause failures.

    - #### getRawFailure

          public abstract java.lang.Throwable getRawFailure()

      Returns the raw failure.
      Returns:
        the raw failure

    - #### getDetails

          public abstract TestFailureDetails getDetails()

      Returns structural information about the failure.
      Returns:
        the failure structure

    - #### fromTestAssertionFailure

          public static TestFailure fromTestAssertionFailure​(java.lang.Throwable failure,
                                                             java.lang.String expected,
                                                             java.lang.String actual)

      Creates a new TestFailure instance from an assertion failure.
      Parameters:
        `failure` - the assertion failure
        `expected` - the expected value for the failure; can be `null`
        `actual` - the actual value for the failure; can be `null`
      Returns:
        the new instance

    - #### fromTestAssertionFailure

          public static TestFailure fromTestAssertionFailure​(java.lang.Throwable failure,
                                                             java.lang.String expected,
                                                             java.lang.String actual,
                                                             java.util.List<TestFailure> causes)

      Creates a new TestFailure instance from an assertion failure.
      Parameters:
        `failure` - the assertion failure
        `expected` - the expected value for the failure; can be `null`
        `actual` - the actual value for the failure; can be `null`
        `causes` - the list of cause failures; can be `null`
      Returns:
        the new instance

    - #### fromTestFrameworkFailure

          public static TestFailure fromTestFrameworkFailure​(java.lang.Throwable failure)

      Creates a new TestFailure instance from a test framework failure.
      Parameters:
        `failure` - the failure
      Returns:
        the new instance

    - #### fromTestFrameworkFailure

          public static TestFailure fromTestFrameworkFailure​(java.lang.Throwable failure,
                                                             java.util.List<TestFailure> causes)

      Creates a new TestFailure instance from a test framework failure.
      Parameters:
        `failure` - the failure
        `causes` - the list of cause failures; can be `null`
      Returns:
        the new instance