Class ComparisonFailure

  • All Implemented Interfaces:
    java.io.Serializable

    public class ComparisonFailure
    extends AssertionFailedError
    Thrown when an assert equals for Strings failed. Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ComparisonFailure​(java.lang.String message, java.lang.String expected, java.lang.String actual)
      Constructs a comparison failure.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getActual()
      Gets the actual string value
      java.lang.String getExpected()
      Gets the expected string value
      java.lang.String getMessage()
      Returns "..." in place of common prefix and "..." in place of common suffix between expected and actual.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • fExpected

        private java.lang.String fExpected
      • fActual

        private java.lang.String fActual
    • Constructor Detail

      • ComparisonFailure

        public ComparisonFailure​(java.lang.String message,
                                 java.lang.String expected,
                                 java.lang.String actual)
        Constructs a comparison failure.
        Parameters:
        message - the identifying message or null
        expected - the expected string value
        actual - the actual string value
    • Method Detail

      • getMessage

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

        public java.lang.String getActual()
        Gets the actual string value
        Returns:
        the actual string value
      • getExpected

        public java.lang.String getExpected()
        Gets the expected string value
        Returns:
        the expected string value