momeunit.framework
Class TestFailure

java.lang.Object
  extended by momeunit.framework.TestFailure

public class TestFailure
extends Object

Describes a test failure or error. There are two kinds of test failures:

This class represents an association of test and exception (either AssertionFailedError thrown as result of test failure, or Throwable thrown while executing this test). Contains methods for checking the kind of failure and printing the stack-trace of thrown exception.

Version:
1.1.2
Author:
Sergio Morozov
See Also:
TestResult

Field Summary
protected  Throwable problem
          Throwable thrown while executing test.
protected  Test test
          Test instance that failed.
 
Constructor Summary
TestFailure(Test failedTest, Throwable thrownException)
          Instantiates a TestFailure with the given Test and Throwable.
 
Method Summary
 Test failedTest()
          Returns the failed test.
 boolean isFailure()
          Checks is this TestFailure a result of failed assertion or thrown error.
 void printTrace()
          Prints stack-trace of thrown exception to the standard error output.
 Throwable thrownException()
          Returns the thrown exception.
 String toString()
          Returns a short description of this TestFailure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

test

protected Test test
Test instance that failed.

Since:
1.0

problem

protected Throwable problem
Throwable thrown while executing test.

Since:
1.0
Constructor Detail

TestFailure

public TestFailure(Test failedTest,
                   Throwable thrownException)
Instantiates a TestFailure with the given Test and Throwable.

Parameters:
failedTest - test that failed.
thrownException - Throwable thrown while executing test.
Since:
1.0
Method Detail

failedTest

public Test failedTest()
Returns the failed test.

Returns:
failed test.
Since:
1.0

thrownException

public Throwable thrownException()
Returns the thrown exception.

Returns:
thrown exception.
Since:
1.0

isFailure

public boolean isFailure()
Checks is this TestFailure a result of failed assertion or thrown error.

Returns:
true if this TestFailure is a result of failed assertion, false otherwise.
Since:
1.0

toString

public String toString()
Returns a short description of this TestFailure.

Overrides:
toString in class Object
Returns:
short description of this TestFailure.
Since:
1.0
See Also:
Object.toString()

printTrace

public void printTrace()
Prints stack-trace of thrown exception to the standard error output.

Since:
1.0