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
AssertionFailedErroris 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
- Author:
- Sam Brannen, Marc Philipp
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AssertionFailedError()Constructs 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
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.StringtoString()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 anAssertionFailedErrorwith an empty message, no cause, and no expected/actual values.
-
AssertionFailedError
public AssertionFailedError(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(String message, Object expected, 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(String message, 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(String message, Object expected, Object actual, 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
-
-
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 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.
-
-