Interface StructuralAssertions


  • @API(status=STABLE)
    public interface StructuralAssertions
    Allows to customize how structured data is compared in order to check whether a snapshot matches an actual test result.
    See Also:
    SnapshotSerializer, StructuredData
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void assertEquals​(java.lang.String storedSnapshot, java.lang.String serializedActual)
      Structurally compares two serialized objects.
    • Method Detail

      • assertEquals

        void assertEquals​(java.lang.String storedSnapshot,
                          java.lang.String serializedActual)
                   throws java.lang.AssertionError
        Structurally compares two serialized objects. If comparison fails, this method should throw an AssertionError with a helpful error message.

        Note that, if you don't throw an instance of AssertionFailedError then the framework will take care of rethrowing your assertion failure as an AssertionFailedError to make sure that the diff can be viewed in the IDE's diff viewer.

        Parameters:
        storedSnapshot - The persisted snapshot.
        serializedActual - The serialized actual test result.
        Throws:
        java.lang.AssertionError - If both objects are not "identical" according to this implementation.
        SnapshotException - If any kind of technical error occurs during comparison.
        API Note:
        Implementors are advised to throw AssertionFailedError instead of plain AssertionError. This allows the user to see an IDE generated diff of the actual and expected values in most IDEs.