Package org.assertj.core.api
Class Fail
java.lang.Object
org.assertj.core.api.Fail
Common failures.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFail()This constructor is protected to make it possible to subclass this class. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidThrows anAssertionErrorwith the given message.static voidThrows anAssertionErrorwith the given message built asString.format(String, Object...).static voidThrows anAssertionErrorwith the given message and with theThrowablethat caused the failure.static voidfailBecauseExceptionWasNotThrown(Class<? extends Throwable> throwableClass) Throws anAssertionErrorwith a message explaining that aThrowableof given class was expected to be thrown but had not been.static voidsetRemoveAssertJRelatedElementsFromStackTrace(boolean removeAssertJRelatedElementsFromStackTrace) Sets whether we remove elements related to AssertJ from assertion error stack trace.static voidshouldHaveThrown(Class<? extends Throwable> throwableClass) Throws anAssertionErrorwith a message explaining that aThrowableof given class was expected to be thrown but had not been.
-
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
-
setRemoveAssertJRelatedElementsFromStackTrace
public static void setRemoveAssertJRelatedElementsFromStackTrace(boolean removeAssertJRelatedElementsFromStackTrace) Sets whether we remove elements related to AssertJ from assertion error stack trace.- Parameters:
removeAssertJRelatedElementsFromStackTrace- flag.
-
fail
Throws anAssertionErrorwith the given message.- Parameters:
failureMessage- error message.- Throws:
AssertionError- with the given message.
-
fail
Throws anAssertionErrorwith the given message built asString.format(String, Object...).- Parameters:
failureMessage- error message.args- Arguments referenced by the format specifiers in the format string.- Throws:
AssertionError- with the given built message.
-
fail
Throws anAssertionErrorwith the given message and with theThrowablethat caused the failure.- Parameters:
failureMessage- the description of the failed assertion. It can benull.realCause- cause of the error.- Throws:
AssertionError- with the given message and with theThrowablethat caused the failure.
-
failBecauseExceptionWasNotThrown
Throws anAssertionErrorwith a message explaining that aThrowableof given class was expected to be thrown but had not been.- Parameters:
throwableClass- the Throwable class that was expected to be thrown.- Throws:
AssertionError- with a message explaining that aThrowableof given class was expected to be thrown but had not been.shouldHaveThrown(Class)can be used as a replacement.
-
shouldHaveThrown
Throws anAssertionErrorwith a message explaining that aThrowableof given class was expected to be thrown but had not been.- Parameters:
throwableClass- the Throwable class that was expected to be thrown.- Throws:
AssertionError- with a message explaining that aThrowableof given class was expected to be thrown but had not been.
-