Package org.junit.runner.notification
Class Failure
- java.lang.Object
- org.junit.runner.notification.Failure
- All Implemented Interfaces:
Serializable
public class Failure extends Object implements Serializable
AFailure
holds a description of the failed test and the exception that was thrown while running it. In most cases theDescription
will be of a single test. However, if problems are encountered while constructing the test (for example, if aBeforeClass
method is not static), it may describe something other than a single test.- Since:
- 4.0
- See Also:
- Serialized Form
Constructor Summary
Constructors Constructor Description Failure(Description description, Throwable thrownException)
Constructs aFailure
with the given description and exception.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Description
getDescription()
Throwable
getException()
String
getMessage()
Convenience methodString
getTestHeader()
String
getTrace()
Convenience methodString
toString()
Constructor Detail
Failure
public Failure(Description description, Throwable thrownException)
Constructs aFailure
with the given description and exception.- Parameters:
description
- aDescription
of the test that failedthrownException
- the exception that was thrown while running the test
Method Detail
getTestHeader
public String getTestHeader()
- Returns:
- a user-understandable label for the test
getDescription
public Description getDescription()
- Returns:
- the raw description of the context of the failure.
getException
public Throwable getException()
- Returns:
- the exception thrown
getMessage
public String getMessage()
Convenience method- Returns:
- the message of the thrown exception