org.junit.runner.notification

Class Failure


public class Failure
extends java.lang.Object

A Failure holds a description of the failed test and the exception that was thrown while running it. In most cases the Description will be of a single test. However, if problems are encountered while constructing the test (for example, if a BeforeClass method is not static), it may describe something other than a single test.

Constructor Summary

Failure(Description description, Throwable thrownException)
Constructs a Failure with the given description and exception.

Method Summary

@Override
String toString()
Description
getDescription()
Throwable
getException()
String
getMessage()
Convenience method
String
getTestHeader()
String
getTrace()
Convenience method

Constructor Details

Failure

public Failure(Description description,
               Throwable thrownException)
Constructs a Failure with the given description and exception.
Parameters:
description - a Description of the test that failed
thrownException - the exception that was thrown while running the test

Method Details

String toString

public @Override String toString()

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

getTestHeader

public String getTestHeader()
Returns:
a user-understandable label for the test

getTrace

public String getTrace()
Convenience method
Returns:
the printed form of the exception