org.fest.assertions.api
Class Fail

java.lang.Object
  extended by org.fest.assertions.api.Fail

public final class Fail
extends Object

Common failures.

Author:
Alex Ruiz, Yvonne Wang, Joel Costigliola

Constructor Summary
protected Fail()
          This constructor is protected to make it possible to subclass this class.
 
Method Summary
static void fail(String failureMessage)
          Fails with the given message.
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 Exception> exceptionClass)
          Throws an AssertionError with a message explaining that an expection of given exceptionClass type was expected to be thrown but had not been.
static void setRemoveFestRelatedElementsFromStackTrace(boolean removeFestRelatedElementsFromStackTrace)
          Sets wether we remove elements related to Fest from assertion error stack trace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

setRemoveFestRelatedElementsFromStackTrace

public static void setRemoveFestRelatedElementsFromStackTrace(boolean removeFestRelatedElementsFromStackTrace)
Sets wether we remove elements related to Fest from assertion error stack trace.

Parameters:
removeFestRelatedElementsFromStackTrace - flag.

fail

public static void fail(String failureMessage)
Fails 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 Exception> exceptionClass)
Throws an AssertionError with a message explaining that an expection of given exceptionClass type was expected to be thrown but had not been.

Parameters:
exceptionClass - the class exception that was expected to be thrown.
Throws:
AssertionError - with a message explaining that an expection of given exceptionClass type was expected to be thrown but had not been.


Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.