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 anAssertionFailedErrorwith an empty message, no cause, and no expected/actual values.AssertionFailedError(String message) Constructs anAssertionFailedErrorwith a message, no cause, and no expected/actual values.AssertionFailedError(String message, Object expected, Object actual) Constructs anAssertionFailedErrorwith a message and expected/actual values but without a cause.AssertionFailedError(String message, Object expected, Object actual, Throwable cause) Constructs anAssertionFailedErrorwith a message, expected/actual values, and a cause.AssertionFailedError(String message, Throwable cause) Constructs anAssertionFailedErrorwith 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.booleanReturnstrueif an actual value was supplied via an appropriate constructor.booleanReturnstrueif 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 anAssertionFailedErrorwith an empty message, no cause, and no expected/actual values. -
AssertionFailedError
Constructs anAssertionFailedErrorwith a message, no cause, and no expected/actual values.- Parameters:
message- the detail message;nullor blank will be converted to the emptyString
-
AssertionFailedError
Constructs anAssertionFailedErrorwith a message and expected/actual values but without a cause.Actual and expected values may be
FileInfoinstances.- Parameters:
message- the detail message;nullor blank will be converted to the emptyStringexpected- the expected value; may benullactual- the actual value; may benull
-
AssertionFailedError
Constructs anAssertionFailedErrorwith a message and a cause but without expected/actual values.- Parameters:
message- the detail message;nullor blank will be converted to the emptyStringcause- the cause of the failure
-
AssertionFailedError
Constructs anAssertionFailedErrorwith a message, expected/actual values, and a cause.- Parameters:
message- the detail message;nullor blank will be converted to the emptyStringexpected- the expected value; may benullactual- the actual value; may benullcause- the cause of the failure
-
-
Method Details
-
isExpectedDefined
public boolean isExpectedDefined()Returnstrueif an expected value was supplied via an appropriate constructor.- See Also:
-
isActualDefined
public boolean isActualDefined()Returnstrueif 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
nullor blank messages to the emptyString, this method only includes non-empty messages in its return value.
-