Package org.opentest4j
Class AssertionFailedError
java.lang.Object
java.lang.Throwable
java.lang.Error
java.lang.AssertionError
org.opentest4j.AssertionFailedError
- All Implemented Interfaces:
Serializable
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.
- Since:
- 1.0
- Author:
- Sam Brannen, Marc Philipp
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs anAssertionFailedError
with an empty message, no cause, and no expected/actual values.AssertionFailedError
(String message) Constructs anAssertionFailedError
with a message, no cause, and no expected/actual values.AssertionFailedError
(String message, Object expected, Object actual) Constructs anAssertionFailedError
with a message and expected/actual values but without a cause.AssertionFailedError
(String message, Object expected, Object actual, Throwable cause) Constructs anAssertionFailedError
with a message, expected/actual values, and a cause.AssertionFailedError
(String message, Throwable cause) Constructs anAssertionFailedError
with a message and a cause but without expected/actual values. -
Method Summary
Modifier and TypeMethodDescriptionReturns the wrapped actual value if it is defined; otherwisenull
.Returns the wrapped expected value if it is defined; otherwisenull
.boolean
Returnstrue
if an actual value was supplied via an appropriate constructor.boolean
Returnstrue
if an expected value was supplied via an appropriate constructor.toString()
Returns a short description of this assertion error using the same format asThrowable.toString()
.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
AssertionFailedError
public AssertionFailedError()Constructs anAssertionFailedError
with an empty message, no cause, and no expected/actual values. -
AssertionFailedError
Constructs anAssertionFailedError
with a message, no cause, and no expected/actual values.- Parameters:
message
- the detail message;null
or blank will be converted to the emptyString
-
AssertionFailedError
Constructs anAssertionFailedError
with a message and expected/actual values but without a cause.Actual and expected values may be
FileInfo
instances.- Parameters:
message
- the detail message;null
or blank will be converted to the emptyString
expected
- the expected value; may benull
actual
- the actual value; may benull
-
AssertionFailedError
Constructs anAssertionFailedError
with a message and a cause but without expected/actual values.- Parameters:
message
- the detail message;null
or blank will be converted to the emptyString
cause
- the cause of the failure
-
AssertionFailedError
Constructs anAssertionFailedError
with a message, expected/actual values, and a cause.- Parameters:
message
- the detail message;null
or blank will be converted to the emptyString
expected
- the expected value; may benull
actual
- the actual value; may benull
cause
- the cause of the failure
-
-
Method Details
-
isExpectedDefined
public boolean isExpectedDefined()Returnstrue
if an expected value was supplied via an appropriate constructor.- See Also:
-
isActualDefined
public boolean isActualDefined()Returnstrue
if an actual value was supplied via an appropriate constructor.- See Also:
-
getExpected
Returns the wrapped expected value if it is defined; otherwisenull
.- See Also:
-
getActual
Returns the wrapped actual value if it is defined; otherwisenull
.- See Also:
-
toString
Returns a short description of this assertion error using the same format asThrowable.toString()
.Since the constructors of this class convert supplied
null
or blank messages to the emptyString
, this method only includes non-empty messages in its return value.
-