Class Fail


  • public final class Fail
    extends Object
    Common failures.
    Author:
    Alex Ruiz, Yvonne Wang, Joel Costigliola
    • Constructor Detail

      • 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 Detail

      • setRemoveAssertJRelatedElementsFromStackTrace

        public static void setRemoveAssertJRelatedElementsFromStackTrace​(boolean removeAssertJRelatedElementsFromStackTrace)
        Sets whether we remove elements related to AssertJ from assertion error stack trace.
        Parameters:
        removeAssertJRelatedElementsFromStackTrace - flag.
      • fail

        public static void fail​(String failureMessage)
        Throws an AssertionError with the given message.
        Parameters:
        failureMessage - error message.
        Throws:
        AssertionError - with the given message.
      • fail

        public static void fail​(String failureMessage,
                                Throwable realCause)
        Throws an AssertionError with the given message and with the Throwable that caused the failure.
        Parameters:
        failureMessage - the description of the failed assertion. It can be null.
        realCause - cause of the error.
        Throws:
        AssertionError - with the given message and with the Throwable that caused the failure.
      • failBecauseExceptionWasNotThrown

        public 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.
        Parameters:
        throwableClass - the Throwable class that was expected to be thrown.
        Throws:
        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.
      • shouldHaveThrown

        public 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.
        Parameters:
        throwableClass - the Throwable class that was expected to be thrown.
        Throws:
        AssertionError - with a message explaining that a Throwable of given class was expected to be thrown but had not been.