Package org.fest.assertions
Class Fail
java.lang.Object
org.fest.assertions.Fail
Understands failure methods.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFail()This constructor is protected to make it possible to subclass this class. -
Method Summary
Modifier and TypeMethodDescriptionprotected static AssertionErrorcomparisonFailed(Description description, Object actual, Object expected) Returns adescribing a comparison failure.AssertionErrorstatic voidfail()Fails with no message.static AssertionErrorFails with the given message.static voidThrows anwith the given message and with theAssertionErrorthat caused the failure.Throwableprivate static voidfail(Description description, Object[] message) protected static voidfailIfActualIsNull(String customErrorMessage, Description description, Object actual) Throws anif the actual value isAssertionErrornull.protected static voidfailIfEqual(String customErrorMessage, Description descriptionOfActual, Object actual, Object other) Throws anif the given objects are equal.AssertionErrorprotected static voidfailIfNotEqual(String customErrorMessage, Description descriptionOfActual, Object actual, Object expected) Throws anif 'actual' is not equal to 'expected'.AssertionErrorprotected static voidfailIfNotNull(String customErrorMessage, Description description, Object o) Throws anif the given object is notAssertionErrornull.protected static voidfailIfNotSame(String customErrorMessage, Description descriptionOfActual, Object actual, Object other) Throws anif the given objects are not the same.AssertionErrorprotected static voidfailIfNull(String customErrorMessage, Description description, Object o) Throws anif the given object isAssertionErrornull.protected static voidfailIfSame(String customErrorMessage, Description descriptionOfActual, Object actual, Object other) Throws anif the given objects are the same.AssertionErrorstatic AssertionErrorCreates awith the given message.AssertionErrorprotected static voidfailWithMessage(String customErrorMessage) Throws anonly if the given custom message is notAssertionErrornull.protected static voidfailWithMessage(String customErrorMessage, Throwable realCause) Throws anonly if the given custom message is notAssertionErrornull.
-
Constructor Details
-
Fail
protected Fail()This constructor is protected to make it possible to subclass this class. Since all its methods are static, there is no point on creating a new instance of it.
-
-
Method Details
-
fail
public static void fail()Fails with no message.- Throws:
AssertionError- without any message.
-
failIfEqual
protected static void failIfEqual(String customErrorMessage, Description descriptionOfActual, Object actual, Object other) Throws anif the given objects are equal.AssertionError- Parameters:
customErrorMessage- any custom error message. This message will replace the default one only if it (the custom message) is notnull.descriptionOfActual- the description of the actual value.actual- the actual object.other- the object to compare to.- Throws:
AssertionError- if the given objects are equal.- Since:
- 1.2
-
failIfNotEqual
protected static void failIfNotEqual(String customErrorMessage, Description descriptionOfActual, Object actual, Object expected) Throws anif 'actual' is not equal to 'expected'. If JUnit 4 (or greater) is in the classpath, this method will throw aAssertionErrorComparisonFailureinstead. More details about this feature can be found here.- Parameters:
customErrorMessage- any custom error message. This message will replace the default one only if it (the custom message) is notnull.descriptionOfActual- the description of the actual value.actual- the actual object.expected- the expected object.- Throws:
AssertionError- if the given objects are not equal.- Since:
- 1.2
-
comparisonFailed
protected static AssertionError comparisonFailed(Description description, Object actual, Object expected) Returns adescribing a comparison failure.AssertionError- Parameters:
description- the description of the comparison.actual- the actual value.expected- the expected value.- Returns:
- a
AssertionErrordescribing the comparison failure. - Since:
- 1.3
-
failIfActualIsNull
protected static void failIfActualIsNull(String customErrorMessage, Description description, Object actual) Throws anif the actual value isAssertionErrornull.- Parameters:
customErrorMessage- any custom error message. This message will replace the default one only if it (the custom message) is notnull.description- the description of the actual value.actual- the actual value.- Throws:
AssertionError- if the actual value isnull.- Since:
- 1.3
-
failIfNull
Throws anif the given object isAssertionErrornull.- Parameters:
customErrorMessage- any custom error message. This message will replace the default one only if it (the custom message) is notnull.description- the description of the given object.o- the given object.- Throws:
AssertionError- if the given object isnull.- Since:
- 1.2
-
failIfNotNull
Throws anif the given object is notAssertionErrornull.- Parameters:
customErrorMessage- any custom error message. This message will replace the default one only if it (the custom message) is notnull.description- the description of the given object.o- the given object.- Throws:
AssertionError- if the given object is notnull.- Since:
- 1.2
-
failIfSame
protected static void failIfSame(String customErrorMessage, Description descriptionOfActual, Object actual, Object other) Throws anif the given objects are the same.AssertionError- Parameters:
customErrorMessage- any custom error message. This message will replace the default one only if it (the custom message) is notnull.descriptionOfActual- the description of the actual value.actual- the actual object.other- the object to compare to.- Throws:
AssertionError- if the given objects are the same.- Since:
- 1.2
-
failIfNotSame
protected static void failIfNotSame(String customErrorMessage, Description descriptionOfActual, Object actual, Object other) Throws anif the given objects are not the same.AssertionError- Parameters:
customErrorMessage- any custom error message. This message will replace the default one only if it (the custom message) is notnull.descriptionOfActual- the description of the actual value.actual- the actual object.other- the object to compare to.- Throws:
AssertionError- if the given objects are not the same.- Since:
- 1.2
-
fail
-
failWithMessage
Throws anonly if the given custom message is notAssertionErrornull.- Parameters:
customErrorMessage- the custom error message.- Throws:
AssertionError- only if the custom error message is notnull.- Since:
- 1.2
-
failWithMessage
Throws anonly if the given custom message is notAssertionErrornull.- Parameters:
customErrorMessage- the custom error message.realCause- cause of the error.- Throws:
AssertionError- only if the custom error message is notnull.- Since:
- 1.2
-
fail
Throws anwith the given message and with theAssertionErrorthat caused the failure.Throwable- Parameters:
description- the description of the failed assertion. It can benull.realCause- cause of the error.
-
fail
Fails with the given message.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 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:
message- error message.- Returns:
- the thrown
AssertionError. - Throws:
AssertionError- with the given message.- See Also:
-
failure
Creates awith the given message.AssertionError- Parameters:
message- the message of the exception to create.- Returns:
- the created exception.
- Since:
- 1.2
-