Name

ComparisonFailure

Description

ComparisonFailure (see Figure B-3) is a specialized subclass of AssertionFailedError. It is thrown only by the versions of assertEquals( ) that compare Strings.

The class ComparisonFailure
Figure B-3. The class ComparisonFailure

Declaration

public class ComparisonFailure
extends AssertionFailedError

Constructors

ComparisonFailure(String message, String expected, String actual)

The constructor for ComparisonFailure.

Public Methods

String getMessage( )

Returns the failure description message. The redundant parts of the compared Strings are replaced with "...” so that only the parts that differ are reported.

Protected/Private Methods

None.

Attributes

private String fActual private String fExpected

The private attributes containing copies of the strings being compared.

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.