public class

ComparisonFailure

extends AssertionError
java.lang.Object
   ↳ java.lang.Throwable
     ↳ java.lang.Error
       ↳ java.lang.AssertionError
         ↳ org.junit.ComparisonFailure

Class Overview

Thrown when an assertEquals(String, String) fails. Create and throw a ComparisonFailure manually if you want to show users the difference between two complex strings. Inspired by a patch from Alex Chaffee (alex@purpletech.com)

Summary

Public Constructors
ComparisonFailure(String message, String expected, String actual)
Constructs a comparison failure.
Public Methods
String getActual()
Returns the actual string value
String getExpected()
Returns the expected string value
String getMessage()
Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.
[Expand]
Inherited Methods
From class java.lang.Throwable
From class java.lang.Object

Public Constructors

public ComparisonFailure (String message, String expected, String actual)

Constructs a comparison failure.

Parameters
message the identifying message or null
expected the expected string value
actual the actual string value

Public Methods

public String getActual ()

Returns the actual string value

Returns
  • the actual string value

public String getExpected ()

Returns the expected string value

Returns
  • the expected string value

public String getMessage ()

Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.

See Also