Package org.fest.assertions
Class Assert
java.lang.Object
org.fest.assertions.Assert
- Direct Known Subclasses:
GenericAssert
Understands the base class for all assertion methods for objects and primitives.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final StringReturns the message to use when a failure occurs, if one has been specified.final StringReturns the description of the actual value in this assertion.protected final voidSets the description of the actual value, to be used in as message of anythrown when an assertion fails.AssertionErrorprotected final voidSets the description of the actual value, to be used in as message of anythrown when an assertion fails.AssertionErrorfinal booleanThrowsif called.UnsupportedOperationExceptionprotected final AssertionErrorFails by throwing an.AssertionErrorprotected final voidFails by throwing an.AssertionErrorprotected final voidThrows anonly if the the custom message in this assertion object is notAssertionErrornull.protected final voidfailIfCustomMessageIsSet(Throwable realCause) Throws anonly if the the custom message in this assertion object is notAssertionErrornull.protected final AssertionErrorCreates an, adding the description of the actual value to the given message.AssertionErrorprotected final StringformattedErrorMessage(String message) Returns the given message formatted as follows:final inthashCode()Always returns 1.protected final DescriptionReturns the description of the actual value in this assertion.protected final voidreplaceDefaultErrorMessagesWith(String message) Specifies the message to use in case of a failure, replacing the default one.
-
Field Details
-
description
-
errorMessage
-
-
Constructor Details
-
Assert
public Assert()
-
-
Method Details
-
description
Returns the description of the actual value in this assertion.- Returns:
- the description of the actual value in this assertion.
-
description
Sets the description of the actual value, to be used in as message of anythrown when an assertion fails.AssertionError- Parameters:
d- the new description.
-
description
Sets the description of the actual value, to be used in as message of anythrown when an assertion fails.AssertionError- Parameters:
d- the new description.
-
rawDescription
Returns the description of the actual value in this assertion.- Returns:
- the description of the actual value in this assertion.
- Since:
- 1.2
-
formattedErrorMessage
Returns the given message formatted as follows:[assertion description] given message.
- Parameters:
message- the message to format.- Returns:
- the formatted message.
-
replaceDefaultErrorMessagesWith
Specifies the message to use in case of a failure, replacing the default one.- Parameters:
message- the new error message.
-
customErrorMessage
Returns the message to use when a failure occurs, if one has been specified.- Returns:
- the message to use when a failure occurs, or
nullif none has been specified.
-
failIfCustomMessageIsSet
protected final void failIfCustomMessageIsSet()Throws anonly if the the custom message in this assertion object is notAssertionErrornull.- Throws:
AssertionError- only if the custom error message in this assertion object is notnull.- Since:
- 1.2
-
failIfCustomMessageIsSet
Throws anonly if the the custom message in this assertion object is notAssertionErrornull.- Parameters:
realCause- cause of the error.- Throws:
AssertionError- only if the custom error message in this assertion object is notnull.- Since:
- 1.2
-
fail
Fails by throwing an.AssertionError- Parameters:
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.
-
fail
Fails by throwing an.AssertionErrorNote: 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 toAssertionErrorvoid. Since we cannot create an overloaded version with return typevoid, we cannot deprecate this method. Please pretend this method does not return anything :)- Parameters:
reason- the reason for the failure, used as the message for the thrown exception.- Returns:
- the thrown
AssertionError. - Throws:
AssertionError- using the given reason as the message.- See Also:
-
failure
Creates an, adding the description of the actual value to the given message.AssertionError- Parameters:
reason- the reason for the failure, used as the message for the thrown exception.- Returns:
- the created exception.
-
equals
Throwsif called. It is easy to accidentally callUnsupportedOperationExceptioninstead ofequals(Object)isEqualTo.- Overrides:
equalsin classObject- Throws:
UnsupportedOperationException- if this method is called.
-
hashCode
public final int hashCode()Always returns 1.
-