# Class TestFailure

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

@Incubating public abstract class TestFailure extends 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

  Modifier and Type
  Method
  Description
  `static TestFailure`
  `fromFileComparisonFailure(Throwable failure, String expected, String actual, byte[] expectedContent, byte[] actualContent, @Nullable List<TestFailure> causes)`
  Todo
  `static TestFailure`
  `fromTestAssertionFailure(Throwable failure, String expected, String actual)`
  Creates a new TestFailure instance from an assertion failure.
  `static TestFailure`
  `fromTestAssertionFailure(Throwable failure, String expected, String actual, @Nullable List<TestFailure> causes)`
  Creates a new TestFailure instance from an assertion failure.
  `static TestFailure`
  `fromTestFrameworkFailure(Throwable failure)`
  Creates a new TestFailure instance from a test framework failure.
  `static TestFailure`
  `fromTestFrameworkFailure(Throwable failure, @Nullable List<TestFailure> causes)`
  Creates a new `TestFailure` instance from a test framework failure.
  `static TestFailure`
  `fromTestMethodFailure(Throwable failure)`
  Creates a new `TestFailure` instance representing a failure occurring during the execution of a test method.
  `abstract List<TestFailure>`
  `getCauses()`
  Returns the list of causes.
  `abstract TestFailureDetails`
  `getDetails()`
  Returns structural information about the failure.
  `abstract Throwable`
  `getRawFailure()`
  Returns the raw failure.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### TestFailure

    public TestFailure()

- ## Method Details

  - ### getCauses

    public abstract 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.
    Since:
      7.6

  - ### getRawFailure

    public abstract Throwable getRawFailure()
    Returns the raw failure.
    Returns:
      the raw failure
    Since:
      7.6

  - ### getDetails

    public abstract TestFailureDetails getDetails()
    Returns structural information about the failure.
    Returns:
      the failure structure
    Since:
      7.6

  - ### fromTestAssertionFailure

    public static TestFailure fromTestAssertionFailure(Throwable failure, String expected, 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
    Since:
      7.6

  - ### fromTestAssertionFailure

    public static TestFailure fromTestAssertionFailure(Throwable failure, String expected, String actual, @Nullable 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
    Since:
      7.6

  - ### fromFileComparisonFailure

    public static TestFailure fromFileComparisonFailure(Throwable failure, String expected, String actual, byte[] expectedContent, byte[] actualContent, @Nullable List<TestFailure> causes)
    Todo
    Since:
      8.3

  - ### fromTestFrameworkFailure

    public static TestFailure fromTestFrameworkFailure(Throwable failure)
    Creates a new TestFailure instance from a test framework failure.
    Parameters:
      `failure` - the failure
    Returns:
      the new instance
    Since:
      7.6

  - ### fromTestFrameworkFailure

    public static TestFailure fromTestFrameworkFailure(Throwable failure, @Nullable 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
    Since:
      7.6

  - ### fromTestMethodFailure

    @Incubating public static TestFailure fromTestMethodFailure(Throwable failure)
    Creates a new `TestFailure` instance representing a failure occurring during the execution of a test method.
    Parameters:
      `failure` - the failure
    Returns:
      the new instance
    Since:
      9.7.0