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 <T> T |
fail(String failureMessage)
Throws an
AssertionError with the given message. |
static <T> T |
fail(String failureMessage,
Object... args)
Throws an
AssertionError with the given message built as String.format(String, Object...). |
static <T> T |
fail(String failureMessage,
Throwable realCause)
Throws an
AssertionError with the given message and with the Throwable that caused the failure. |
static <T> T |
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 <T> T |
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 <T> T fail(String failureMessage)
AssertionError with the given message.T - dummy return value typefailureMessage - error message.AssertionError - with the given message.public static <T> T fail(String failureMessage, Object... args)
AssertionError with the given message built as String.format(String, Object...).T - dummy return value typefailureMessage - error message.args - Arguments referenced by the format specifiers in the format string.AssertionError - with the given built message.public static <T> T fail(String failureMessage, Throwable realCause)
AssertionError with the given message and with the Throwable that caused the failure.T - dummy return value typefailureMessage - 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 <T> T 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.T - dummy return value typethrowableClass - 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 <T> T 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.T - dummy return value typethrowableClass - 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 © 2014–2019 AssertJ. All rights reserved.