Class AssertionFailedError

  • All Implemented Interfaces:
    java.io.Serializable

    public class AssertionFailedError
    extends java.lang.AssertionError
    AssertionFailedError is an initial draft for a common base class for test-related AssertionErrors.

    In addition to a message and a cause this class stores the expected and actual values of an assertion using the ValueWrapper type.

    WARNING: this is a work in progress and is therefore guaranteed to undergo heavy revisions in the near future based on community feedback.

    Since:
    1.0
    Author:
    Sam Brannen, Marc Philipp
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      AssertionFailedError()
      Constructs an AssertionFailedError with no message, no cause, and no expected/actual values.
      AssertionFailedError​(java.lang.String message)
      Constructs an AssertionFailedError with a message, no cause, and no expected/actual values.
      AssertionFailedError​(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
      Constructs an AssertionFailedError with a message and expected/actual values but without a cause.
      AssertionFailedError​(java.lang.String message, java.lang.Object expected, java.lang.Object actual, java.lang.Throwable cause)
      Constructs an AssertionFailedError with a message, expected/actual values, and a cause.
      AssertionFailedError​(java.lang.String message, java.lang.Throwable cause)
      Constructs an AssertionFailedError with a message and a cause but without expected/actual values.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ValueWrapper getActual()
      Returns the wrapped actual value if it is defined; otherwise null.
      ValueWrapper getExpected()
      Returns the wrapped expected value if it is defined; otherwise null.
      boolean isActualDefined()
      Returns true if the actual value is defined, i.e.
      boolean isExpectedDefined()
      Returns true if the expected value is defined, i.e.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, 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
    • Constructor Detail

      • AssertionFailedError

        public AssertionFailedError()
        Constructs an AssertionFailedError with no message, no cause, and no expected/actual values.
      • AssertionFailedError

        public AssertionFailedError​(java.lang.String message)
        Constructs an AssertionFailedError with a message, no cause, and no expected/actual values.
      • AssertionFailedError

        public AssertionFailedError​(java.lang.String message,
                                    java.lang.Object expected,
                                    java.lang.Object actual)
        Constructs an AssertionFailedError with a message and expected/actual values but without a cause.
      • AssertionFailedError

        public AssertionFailedError​(java.lang.String message,
                                    java.lang.Throwable cause)
        Constructs an AssertionFailedError with a message and a cause but without expected/actual values.
      • AssertionFailedError

        public AssertionFailedError​(java.lang.String message,
                                    java.lang.Object expected,
                                    java.lang.Object actual,
                                    java.lang.Throwable cause)
        Constructs an AssertionFailedError with a message, expected/actual values, and a cause.
    • Method Detail

      • isExpectedDefined

        public boolean isExpectedDefined()
        Returns true if the expected value is defined, i.e. was passed to the constructor.
        See Also:
        getExpected()
      • isActualDefined

        public boolean isActualDefined()
        Returns true if the actual value is defined, i.e. was passed to the constructor.
        See Also:
        getActual()