## 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

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.

Since:
  4.0
See Also:
  Serialized Form

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

Method Summary
`Description` `getDescription()`
`Throwable` `getException()`
`String` `getMessage()` Convenience method
`String` `getTestHeader()`
`String` `getTrace()` Gets the printed form of the exception and its stack trace.
`String` `getTrimmedTrace()` Gets a the printed form of the exception, with a trimmed version of the stack trace.
`String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### 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 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

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### getTrace

    public String getTrace()

  Gets the printed form of the exception and its stack trace.

### getTrimmedTrace

    public 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 String getMessage()

  Convenience method

  Returns:
    the message of the thrown exception

Copyright © 2002–2020 JUnit. All rights reserved.