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 |
|---|---|
static void |
fail(String failureMessage)
Throws an
AssertionError with the given message. |
static void |
fail(String failureMessage,
Object... args)
Throws an
AssertionError with the given message built as String.format(String, Object...). |
static void |
fail(String failureMessage,
Throwable realCause)
Throws an
AssertionError with the given message and with the Throwable that caused the failure. |
static void |
failBecauseExceptionWasNotThrown(Class<? extends Throwable> throwableClass)
Throws an
AssertionError with a message explaining that a Throwable of given class was expected to be thrown
but had not been. |
static void |
setRemoveAssertJRelatedElementsFromStackTrace(boolean removeAssertJRelatedElementsFromStackTrace)
Sets whether we remove elements related to AssertJ from assertion error stack trace.
|
static void |
shouldHaveThrown(Class<? extends Throwable> throwableClass)
Throws an
AssertionError with a message explaining that a Throwable of given class was expected to be thrown
but had not been. |
protected Fail()
public static void setRemoveAssertJRelatedElementsFromStackTrace(boolean removeAssertJRelatedElementsFromStackTrace)
removeAssertJRelatedElementsFromStackTrace - flag.public static void fail(String failureMessage)
AssertionError with the given message.failureMessage - error message.AssertionError - with the given message.public static void fail(String failureMessage, Object... args)
AssertionError with the given message built as String.format(String, Object...).failureMessage - error message.args - Arguments referenced by the format specifiers in the format string.AssertionError - with the given built message.public static void fail(String failureMessage, Throwable realCause)
AssertionError with the given message and with the Throwable that caused the failure.failureMessage - the description of the failed assertion. It can be null.realCause - cause of the error.AssertionError - with the given message and with the Throwable that caused the failure.public static void failBecauseExceptionWasNotThrown(Class<? extends Throwable> throwableClass)
AssertionError with a message explaining that a Throwable of given class was expected to be thrown
but had not been.throwableClass - the Throwable class that was expected to be thrown.AssertionError - with a message explaining that a Throwable of given class was expected to be thrown but had
not been.
shouldHaveThrown(Class) can be used as a replacement.public static void shouldHaveThrown(Class<? extends Throwable> throwableClass)
AssertionError with a message explaining that a Throwable of given class was expected to be thrown
but had not been.throwableClass - the Throwable class that was expected to be thrown.AssertionError - with a message explaining that a Throwable of given class was expected to be thrown but had
not been.Copyright © 2013–2018 AssertJ. All rights reserved.