Name

AssertionFailedError

Description

AssertionFailedError (see Figure B-2) is a class representing an assertion failure. Aside from being a distinct subclass, it is otherwise identical to Error. Thus, it is Throwable and contains a stack trace.

The assert methods in Assert throw an AssertionFailedError (or a subclass of it) when an assertion fails. The AssertionFailedError conveniently captures the stack trace of the code location from which it was thrown, making it easy to find the assertion that failed.

The class AssertionFailedError
Figure B-2. The class AssertionFailedError

Declaration

public class AssertionFailedError
extends java.lang.Error

Constructors

public AssertionFailedError( ) public AssertionFailedError(String message)

The constructors for AssertionFailedError.

Public Methods

None.

Protected/Private Methods

None.

Attributes

None.

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.