Package org.gradle.api.tasks.testing

# 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, 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, 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, List<TestFailure> causes)`
  Creates a new TestFailure instance from a test framework failure.
  `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 java.lang.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.

  - ### getRawFailure

    public abstract 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(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

  - ### 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

  - ### 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

  - ### 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