Package org.opentest4j
Class AssertionFailedError
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Error
-
- java.lang.AssertionError
-
- org.opentest4j.AssertionFailedError
-
- All Implemented Interfaces:
java.io.Serializable
public class AssertionFailedError extends java.lang.AssertionErrorAssertionFailedErroris 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
ValueWrappertype.- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private ValueWrapperactualprivate ValueWrapperexpectedprivate static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description AssertionFailedError()Constructs anAssertionFailedErrorwith an empty message, no cause, and no expected/actual values.AssertionFailedError(java.lang.String message)Constructs anAssertionFailedErrorwith a message, no cause, and no expected/actual values.AssertionFailedError(java.lang.String message, java.lang.Object expected, java.lang.Object actual)Constructs anAssertionFailedErrorwith a message and expected/actual values but without a cause.AssertionFailedError(java.lang.String message, java.lang.Object expected, java.lang.Object actual, java.lang.Throwable cause)Constructs anAssertionFailedErrorwith a message, expected/actual values, and a cause.AssertionFailedError(java.lang.String message, java.lang.Throwable cause)Constructs anAssertionFailedErrorwith a message and a cause but without expected/actual values.privateAssertionFailedError(java.lang.String message, ValueWrapper expected, ValueWrapper actual, java.lang.Throwable cause)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueWrappergetActual()Returns the wrapped actual value if it is defined; otherwisenull.ValueWrappergetExpected()Returns the wrapped expected value if it is defined; otherwisenull.booleanisActualDefined()Returnstrueif an actual value was supplied via an appropriate constructor.booleanisExpectedDefined()Returnstrueif an expected value was supplied via an appropriate constructor.java.lang.StringtoString()Returns a short description of this assertion error using the same format asThrowable.toString().
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
expected
private final ValueWrapper expected
-
actual
private final ValueWrapper actual
-
-
Constructor Detail
-
AssertionFailedError
public AssertionFailedError()
Constructs anAssertionFailedErrorwith an empty message, no cause, and no expected/actual values.
-
AssertionFailedError
public AssertionFailedError(java.lang.String message)
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
public AssertionFailedError(java.lang.String message, java.lang.Object expected, java.lang.Object actual)Constructs anAssertionFailedErrorwith a message and expected/actual values but without a cause.- Parameters:
message- the detail message;nullor blank will be converted to the emptyStringexpected- the expected value; may benullactual- the actual value; may benull
-
AssertionFailedError
public AssertionFailedError(java.lang.String message, java.lang.Throwable cause)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
public AssertionFailedError(java.lang.String message, java.lang.Object expected, java.lang.Object actual, java.lang.Throwable cause)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
-
AssertionFailedError
private AssertionFailedError(java.lang.String message, ValueWrapper expected, ValueWrapper actual, java.lang.Throwable cause)
-
-
Method Detail
-
isExpectedDefined
public boolean isExpectedDefined()
Returnstrueif an expected value was supplied via an appropriate constructor.- See Also:
getExpected()
-
isActualDefined
public boolean isActualDefined()
Returnstrueif 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 java.lang.String 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.- Overrides:
toStringin classjava.lang.Throwable- Returns:
- a string representation of this
AssertionFailedError - Since:
- 1.1.1
-
-