Top Description Fields Constructors Methods
org.opentest4j

public Class AssertionFailedError

extends AssertionError
Class Inheritance

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.

Authors
Sam Brannen, Marc Philipp
Since
1.0

Field Summary

Modifier and TypeField and Description
private final ValueWrapper
private final ValueWrapper
private static final Throwable
private static final long

Constructor Summary

AccessConstructor and Description
public
AssertionFailedError()

Constructs an AssertionFailedError with an empty message, no cause, and no expected/actual values.

public
AssertionFailedError(String
the detail message; null or blank will be converted to the empty String
message
)

Constructs an AssertionFailedError with a message, no cause, and no expected/actual values.

public
AssertionFailedError(String
the detail message; null or blank will be converted to the empty String
message
,
Object
the expected value; may be null
expected
,
Object
the actual value; may be null
actual
)

Constructs an AssertionFailedError with a message and expected/actual values but without a cause.

public
AssertionFailedError(String
the detail message; null or blank will be converted to the empty String
message
,
Throwable
the cause of the failure
cause
)

Constructs an AssertionFailedError with a message and a cause but without expected/actual values.

public
AssertionFailedError(String
the detail message; null or blank will be converted to the empty String
message
,
Object
the expected value; may be null
expected
,
Object
the actual value; may be null
actual
,
Throwable
the cause of the failure
cause
)

Constructs an AssertionFailedError with a message, expected/actual values, and a cause.

private

Method Summary

Modifier and TypeMethod and Description
public ValueWrapper
getActual()

Returns the wrapped actual value if it is defined; otherwise null.

public ValueWrapper
getExpected()

Returns the wrapped expected value if it is defined; otherwise null.

public boolean
isActualDefined()

Returns true if an actual value was supplied via an appropriate constructor.

public boolean
isExpectedDefined()

Returns true if an expected value was supplied via an appropriate constructor.

public String

Returns:

a string representation of this AssertionFailedError
toString
()

Overrides java.lang.Throwable.toString.

Returns a short description of this assertion error using the same format as Throwable#toString().

Field Detail

actualback to summary
private final ValueWrapper actual
expectedback to summary
private final ValueWrapper expected
NO_CAUSEback to summary
private static final Throwable NO_CAUSE
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.AssertionError.serialVersionUID.

Constructor Detail

AssertionFailedErrorback to summary
public AssertionFailedError()

Constructs an AssertionFailedError with an empty message, no cause, and no expected/actual values.

AssertionFailedErrorback to summary
public AssertionFailedError(String message)

Constructs an AssertionFailedError with a message, no cause, and no expected/actual values.

Parameters
message:String

the detail message; null or blank will be converted to the empty String

AssertionFailedErrorback to summary
public AssertionFailedError(String message, Object expected, Object actual)

Constructs an AssertionFailedError with a message and expected/actual values but without a cause.

Actual and expected values may be FileInfo instances.

Parameters
message:String

the detail message; null or blank will be converted to the empty String

expected:Object

the expected value; may be null

actual:Object

the actual value; may be null

AssertionFailedErrorback to summary
public AssertionFailedError(String message, Throwable cause)

Constructs an AssertionFailedError with a message and a cause but without expected/actual values.

Parameters
message:String

the detail message; null or blank will be converted to the empty String

cause:Throwable

the cause of the failure

AssertionFailedErrorback to summary
public AssertionFailedError(String message, Object expected, Object actual, Throwable cause)

Constructs an AssertionFailedError with a message, expected/actual values, and a cause.

Parameters
message:String

the detail message; null or blank will be converted to the empty String

expected:Object

the expected value; may be null

actual:Object

the actual value; may be null

cause:Throwable

the cause of the failure

AssertionFailedErrorback to summary
private AssertionFailedError(String message, ValueWrapper expected, ValueWrapper actual, Throwable cause)

Method Detail

getActualback to summary
public ValueWrapper getActual()

Returns the wrapped actual value if it is defined; otherwise null.

See Also
isActualDefined()
getExpectedback to summary
public ValueWrapper getExpected()

Returns the wrapped expected value if it is defined; otherwise null.

See Also
isExpectedDefined()
isActualDefinedback to summary
public boolean isActualDefined()

Returns true if an actual value was supplied via an appropriate constructor.

See Also
getActual()
isExpectedDefinedback to summary
public boolean isExpectedDefined()

Returns true if an expected value was supplied via an appropriate constructor.

See Also
getExpected()
toStringback to summary
public String toString()

Overrides java.lang.Throwable.toString.

Returns a short description of this assertion error using the same format as Throwable#toString().

Since the constructors of this class convert supplied null or blank messages to the empty String, this method only includes non-empty messages in its return value.

Returns:String

a string representation of this AssertionFailedError

Annotations
@Override
Since
1.1.1