public class AssertionFailedError extends AssertionError
AssertionFailedError
is a common base class for test-related
AssertionErrors
.
In addition to a message and a cause, this class stores the expected
and actual values of an assertion using the ValueWrapper
type.
Constructor and Description |
---|
AssertionFailedError()
Constructs an
AssertionFailedError with no message, no cause,
and no expected/actual values. |
AssertionFailedError(String message)
Constructs an
AssertionFailedError with a message, no cause,
and no expected/actual values. |
AssertionFailedError(String message,
Object expected,
Object actual)
Constructs an
AssertionFailedError with a message and
expected/actual values but without a cause. |
AssertionFailedError(String message,
Object expected,
Object actual,
Throwable cause)
Constructs an
AssertionFailedError with a message,
expected/actual values, and a cause. |
AssertionFailedError(String message,
Throwable cause)
Constructs an
AssertionFailedError with a message and a cause
but without expected/actual values. |
Modifier and Type | Method and Description |
---|---|
ValueWrapper |
getActual()
Returns the wrapped actual value if it is defined; otherwise
null . |
ValueWrapper |
getExpected()
Returns the wrapped expected value if it is defined; otherwise
null . |
String |
getMessage()
Returns the error message, potentially
null . |
boolean |
isActualDefined()
Returns
true if the actual value is defined, i.e. |
boolean |
isExpectedDefined()
Returns
true if the expected value is defined, i.e. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public AssertionFailedError()
AssertionFailedError
with no message, no cause,
and no expected/actual values.public AssertionFailedError(String message)
AssertionFailedError
with a message, no cause,
and no expected/actual values.public AssertionFailedError(String message, Object expected, Object actual)
AssertionFailedError
with a message and
expected/actual values but without a cause.public AssertionFailedError(String message, Throwable cause)
AssertionFailedError
with a message and a cause
but without expected/actual values.public String getMessage()
null
.getMessage
in class Throwable
Throwable.getMessage()
public boolean isExpectedDefined()
true
if the expected value is defined, i.e. was passed
to the constructor.getExpected()
public boolean isActualDefined()
true
if the actual value is defined, i.e. was passed
to the constructor.getActual()
public ValueWrapper getExpected()
null
.isExpectedDefined()
public ValueWrapper getActual()
null
.isActualDefined()