Package org.gradle.api.tasks.testing
Class TestFailure
java.lang.Object
org.gradle.api.tasks.testing.TestFailure
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic TestFailurefromFileComparisonFailure(Throwable failure, String expected, String actual, byte[] expectedContent, byte[] actualContent, List<TestFailure> causes) Todostatic TestFailurefromTestAssertionFailure(Throwable failure, String expected, String actual) Creates a new TestFailure instance from an assertion failure.static TestFailurefromTestAssertionFailure(Throwable failure, String expected, String actual, List<TestFailure> causes) Creates a new TestFailure instance from an assertion failure.static TestFailurefromTestFrameworkFailure(Throwable failure) Creates a new TestFailure instance from a test framework failure.static TestFailurefromTestFrameworkFailure(Throwable failure, List<TestFailure> causes) Creates a new TestFailure instance from a test framework failure.abstract List<TestFailure> Returns the list of causes.abstract TestFailureDetailsReturns structural information about the failure.abstract ThrowableReturns the raw failure.
-
Constructor Details
-
TestFailure
public TestFailure()
-
-
Method Details
-
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
Returns the raw failure.- Returns:
- the raw failure
-
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 failureexpected- the expected value for the failure; can benullactual- the actual value for the failure; can benull- 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 failureexpected- the expected value for the failure; can benullactual- the actual value for the failure; can benullcauses- the list of cause failures; can benull- 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
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 failurecauses- the list of cause failures; can benull- Returns:
- the new instance
-