public final class Fail extends Object
Modifier | Constructor and Description |
---|---|
protected |
Fail()
This constructor is protected to make it possible to subclass this class.
|
Modifier and Type | Method and Description |
---|---|
protected static AssertionError |
comparisonFailed(Description description,
Object actual,
Object expected)
Returns a
describing a comparison failure. |
static void |
fail()
Fails with no message.
|
static AssertionError |
fail(String message)
Fails with the given message.
|
static void |
fail(String description,
Throwable realCause)
Throws an
with the given message and with the
that caused the failure. |
protected static void |
failIfActualIsNull(String customErrorMessage,
Description description,
Object actual)
Throws an
if the actual value is null . |
protected static void |
failIfEqual(String customErrorMessage,
Description descriptionOfActual,
Object actual,
Object other)
Throws an
if the given objects are equal. |
protected static void |
failIfNotEqual(String customErrorMessage,
Description descriptionOfActual,
Object actual,
Object expected)
Throws an
if 'actual' is not equal to 'expected'. |
protected static void |
failIfNotNull(String customErrorMessage,
Description description,
Object o)
Throws an
if the given object is not null . |
protected static void |
failIfNotSame(String customErrorMessage,
Description descriptionOfActual,
Object actual,
Object other)
Throws an
if the given objects are not the same. |
protected static void |
failIfNull(String customErrorMessage,
Description description,
Object o)
Throws an
if the given object is null . |
protected static void |
failIfSame(String customErrorMessage,
Description descriptionOfActual,
Object actual,
Object other)
Throws an
if the given objects are the same. |
static AssertionError |
failure(String message)
Creates a
with the given message. |
protected static void |
failWithMessage(String customErrorMessage)
Throws an
only if the given custom message is not null . |
protected static void |
failWithMessage(String customErrorMessage,
Throwable realCause)
Throws an
only if the given custom message is not null . |
protected Fail()
public static void fail()
AssertionError
- without any message.protected static void failIfEqual(String customErrorMessage, Description descriptionOfActual, Object actual, Object other)
AssertionError
if the given objects are equal.customErrorMessage
- any custom error message. This message will replace the default one only if it (the
custom message) is not null
.descriptionOfActual
- the description of the actual value.actual
- the actual object.other
- the object to compare to.AssertionError
- if the given objects are equal.protected static void failIfNotEqual(String customErrorMessage, Description descriptionOfActual, Object actual, Object expected)
AssertionError
if 'actual' is not equal to 'expected'. If JUnit 4 (or greater) is
in the classpath, this method will throw a ComparisonFailure
instead. More details about this feature
can be found here.customErrorMessage
- any custom error message. This message will replace the default one only if it (the
custom message) is not null
.descriptionOfActual
- the description of the actual value.actual
- the actual object.expected
- the expected object.AssertionError
- if the given objects are not equal.protected static AssertionError comparisonFailed(Description description, Object actual, Object expected)
AssertionError
describing a comparison failure.description
- the description of the comparison.actual
- the actual value.expected
- the expected value.AssertionError
describing the comparison failure.protected static void failIfActualIsNull(String customErrorMessage, Description description, Object actual)
AssertionError
if the actual value is null
.customErrorMessage
- any custom error message. This message will replace the default one only if it (the
custom message) is not null
.description
- the description of the actual value.actual
- the actual value.AssertionError
- if the actual value is null
.protected static void failIfNull(String customErrorMessage, Description description, Object o)
AssertionError
if the given object is null
.customErrorMessage
- any custom error message. This message will replace the default one only if it (the
custom message) is not null
.description
- the description of the given object.o
- the given object.AssertionError
- if the given object is null
.protected static void failIfNotNull(String customErrorMessage, Description description, Object o)
AssertionError
if the given object is not null
.customErrorMessage
- any custom error message. This message will replace the default one only if it (the
custom message) is not null
.description
- the description of the given object.o
- the given object.AssertionError
- if the given object is not null
.protected static void failIfSame(String customErrorMessage, Description descriptionOfActual, Object actual, Object other)
AssertionError
if the given objects are the same.customErrorMessage
- any custom error message. This message will replace the default one only if it (the
custom message) is not null
.descriptionOfActual
- the description of the actual value.actual
- the actual object.other
- the object to compare to.AssertionError
- if the given objects are the same.protected static void failIfNotSame(String customErrorMessage, Description descriptionOfActual, Object actual, Object other)
AssertionError
if the given objects are not the same.customErrorMessage
- any custom error message. This message will replace the default one only if it (the
custom message) is not null
.descriptionOfActual
- the description of the actual value.actual
- the actual object.other
- the object to compare to.AssertionError
- if the given objects are not the same.protected static void failWithMessage(String customErrorMessage)
AssertionError
only if the given custom message is not null
.customErrorMessage
- the custom error message.AssertionError
- only if the custom error message is not null
.protected static void failWithMessage(String customErrorMessage, Throwable realCause)
AssertionError
only if the given custom message is not null
.customErrorMessage
- the custom error message.realCause
- cause of the error.AssertionError
- only if the custom error message is not null
.public static void fail(String description, Throwable realCause)
AssertionError
with the given message and with the Throwable
that caused the failure.description
- the description of the failed assertion. It can be null
.realCause
- cause of the error.public static AssertionError fail(String 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
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 :)
message
- error message.AssertionError
.AssertionError
- with the given message.failure(String)
public static AssertionError failure(String message)
AssertionError
with the given message.message
- the message of the exception to create.Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.