public abstract class Assert extends Object
Constructor and Description |
---|
Assert() |
Modifier and Type | Method and Description |
---|---|
protected String |
customErrorMessage()
Returns the message to use when a failure occurs, if one has been specified.
|
String |
description()
Returns the description of the actual value in this assertion.
|
protected void |
description(Description d)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
protected void |
description(String d)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
boolean |
equals(Object obj)
Throws
if called. |
protected AssertionError |
fail(String reason)
Fails by throwing an
. |
protected void |
fail(String reason,
Throwable cause)
Fails by throwing an
. |
protected void |
failIfCustomMessageIsSet()
Throws an
only if the the custom message in this assertion object is not
null . |
protected void |
failIfCustomMessageIsSet(Throwable realCause)
Throws an
only if the the custom message in this assertion object is not
null . |
protected AssertionError |
failure(String reason)
Creates an
, adding the description of the actual value to the given message. |
protected String |
formattedErrorMessage(String message)
Returns the given message formatted as follows:
|
int |
hashCode()
Always returns 1.
|
protected Description |
rawDescription()
Returns the description of the actual value in this assertion.
|
protected void |
replaceDefaultErrorMessagesWith(String message)
Specifies the message to use in case of a failure, replacing the default one.
|
public final String description()
protected final void description(String d)
AssertionError
thrown when an assertion fails.d
- the new description.protected final void description(Description d)
AssertionError
thrown when an assertion fails.d
- the new description.protected final Description rawDescription()
protected final String formattedErrorMessage(String message)
[assertion description] given message.
message
- the message to format.protected final void replaceDefaultErrorMessagesWith(String message)
message
- the new error message.protected final String customErrorMessage()
null
if none has been specified.protected final void failIfCustomMessageIsSet()
AssertionError
only if the the custom message in this assertion object is not
null
.AssertionError
- only if the custom error message in this assertion object is not null
.protected final void failIfCustomMessageIsSet(Throwable realCause)
AssertionError
only if the the custom message in this assertion object is not
null
.realCause
- cause of the error.AssertionError
- only if the custom error message in this assertion object is not null
.protected final void fail(String reason, Throwable cause)
AssertionError
.reason
- the reason for the failure, used as the message for the thrown exception.cause
- the root cause of the failure, included in the thrown exception.protected final AssertionError fail(String reason)
AssertionError
.
Note: This method appears to return
, but it is really not the
case, since the exception is thrown and not returned. In version 2.0 the return type of this method will change
to AssertionError
void
. Since we cannot create an overloaded version with return type void
, we cannot
deprecate this method. Please pretend this method does not return anything :)
reason
- the reason for the failure, used as the message for the thrown exception.AssertionError
.AssertionError
- using the given reason as the message.failure(String)
protected final AssertionError failure(String reason)
AssertionError
, adding the description of the actual value to the given message.reason
- the reason for the failure, used as the message for the thrown exception.public final boolean equals(Object obj)
UnsupportedOperationException
if called. It is easy to accidentally call
equals(Object)
instead of isEqualTo
.equals
in class Object
UnsupportedOperationException
- if this method is called.Copyright © 2007-2013 FEST (Fixtures for Easy Software Testing). All Rights Reserved.