class TestFailure (View source)

A TestFailure collects a failed test together with the caught exception.

Properties

protected Test|null $failedTest
protected Throwable $thrownException

Methods

__construct(Test $failedTest, Throwable $t)

Constructs a TestFailure with the given test and exception.

string
toString()

Returns a short description of the failure.

string
getExceptionAsString()

Returns a description for the thrown exception.

static string
exceptionToString(Throwable $e)

Returns a description for an exception.

string
getTestName()

Returns the name of the failing test (including data set, if any).

Test|null
failedTest()

Returns the failing test.

thrownException()

Gets the thrown exception.

string
exceptionMessage()

Returns the exception's message.

bool
isFailure()

Returns true if the thrown exception is of type AssertionFailedError.

Details

__construct(Test $failedTest, Throwable $t)

Constructs a TestFailure with the given test and exception.

Parameters

Test $failedTest
Throwable $t

string toString()

Returns a short description of the failure.

Return Value

string

string getExceptionAsString()

Returns a description for the thrown exception.

Return Value

string

static string exceptionToString(Throwable $e)

Returns a description for an exception.

Parameters

Throwable $e

Return Value

string

string getTestName()

Returns the name of the failing test (including data set, if any).

Return Value

string

Test|null failedTest()

Returns the failing test.

Note: The test object is not set when the test is executed in process isolation.

Return Value

Test|null

See also

Exception

Throwable thrownException()

Gets the thrown exception.

Return Value

Throwable

string exceptionMessage()

Returns the exception's message.

Return Value

string

bool isFailure()

Returns true if the thrown exception is of type AssertionFailedError.

Return Value

bool