Package org.junit

Class ComparisonFailure

All Implemented Interfaces:
Serializable

public class ComparisonFailure extends AssertionError
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)

Since:
4.0
See Also:
  • Field Details

  • Constructor Details

    • ComparisonFailure

      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
  • Method Details

    • getMessage

      public String getMessage()
      Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.
      Overrides:
      getMessage in class Throwable
      See Also:
    • getActual

      public String getActual()
      Returns the actual string value
      Returns:
      the actual string value
    • getExpected

      public String getExpected()
      Returns the expected string value
      Returns:
      the expected string value