Package org.junit.runner.notification
Class Failure
- java.lang.Object
-
- org.junit.runner.notification.Failure
-
- All Implemented Interfaces:
java.io.Serializable
public class Failure extends java.lang.Object implements java.io.Serializable
AFailureholds a description of the failed test and the exception that was thrown while running it. In most cases theDescriptionwill be of a single test. However, if problems are encountered while constructing the test (for example, if aBeforeClassmethod 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, java.lang.Throwable thrownException)Constructs aFailurewith the given description and exception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DescriptiongetDescription()java.lang.ThrowablegetException()java.lang.StringgetMessage()Convenience methodjava.lang.StringgetTestHeader()java.lang.StringgetTrace()Gets the printed form of the exception and its stack trace.java.lang.StringgetTrimmedTrace()Gets a the printed form of the exception, with a trimmed version of the stack trace.java.lang.StringtoString()
-
-
-
Constructor Detail
-
Failure
public Failure(Description description, java.lang.Throwable thrownException)
Constructs aFailurewith the given description and exception.- Parameters:
description- aDescriptionof the test that failedthrownException- the exception that was thrown while running the test
-
-
Method Detail
-
getTestHeader
public java.lang.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 java.lang.Throwable getException()
- Returns:
- the exception thrown
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getTrace
public java.lang.String getTrace()
Gets the printed form of the exception and its stack trace.
-
getTrimmedTrace
public java.lang.String getTrimmedTrace()
Gets a the printed form of the exception, with a trimmed version of the stack trace. This method will attempt to filter out frames of the stack trace that are below the test method call.
-
getMessage
public java.lang.String getMessage()
Convenience method- Returns:
- the message of the thrown exception
-
-