Package org.opentest4j
Class AssertionFailedError
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Error
-
- java.lang.AssertionError
-
- org.opentest4j.AssertionFailedError
-
- All Implemented Interfaces:
Serializable
public class AssertionFailedError extends AssertionError
AssertionFailedError
is a common base class for test-relatedAssertionErrors
.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AssertionFailedError()
Constructs 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueWrapper
getActual()
Returns the wrapped actual value if it is defined; otherwisenull
.ValueWrapper
getExpected()
Returns the wrapped expected value if it is defined; otherwisenull
.boolean
isActualDefined()
Returnstrue
if an actual value was supplied via an appropriate constructor.boolean
isExpectedDefined()
Returnstrue
if an expected value was supplied via an appropriate constructor.String
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 Detail
-
AssertionFailedError
public AssertionFailedError()
Constructs anAssertionFailedError
with an empty message, no cause, and no expected/actual values.
-
AssertionFailedError
public AssertionFailedError(String message)
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
public AssertionFailedError(String message, Object expected, Object actual)
Constructs anAssertionFailedError
with a message and expected/actual values but without 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
-
AssertionFailedError
public AssertionFailedError(String message, Throwable cause)
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
public AssertionFailedError(String message, Object expected, Object actual, Throwable cause)
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 Detail
-
isExpectedDefined
public boolean isExpectedDefined()
Returnstrue
if an expected value was supplied via an appropriate constructor.- See Also:
getExpected()
-
isActualDefined
public boolean isActualDefined()
Returnstrue
if an actual value was supplied via an appropriate constructor.- See Also:
getActual()
-
getExpected
public ValueWrapper getExpected()
Returns the wrapped expected value if it is defined; otherwisenull
.- See Also:
isExpectedDefined()
-
getActual
public ValueWrapper getActual()
Returns the wrapped actual value if it is defined; otherwisenull
.- See Also:
isActualDefined()
-
toString
public String 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.
-
-