Class SnapshotTestResult


  • @API(status=EXPERIMENTAL)
    public final class SnapshotTestResult
    extends java.lang.Object
    Result details of a single snapshot assertion. An instance of this class is returned by every DSL terminal operation.
    Since:
    0.0.2
    • Method Detail

      • forFailedTest

        @API(status=INTERNAL)
        public static SnapshotTestResult forFailedTest​(ContextFiles contextFiles,
                                                       SnapshotFile snapshotFile,
                                                       java.lang.String serializedActual,
                                                       java.lang.Throwable failure)
      • status

        public SnapshotTestResult.SnapshotStatus status()
        Whether snapshot has been created/updated or asserted.
        Returns:
        Whether snapshot has been created/updated or asserted.
      • serializedSnapshot

        @Deprecated(since="1.7.0",
                    forRemoval=true)
        @API(status=DEPRECATED,
             since="1.7.0")
        public SnapshotFile serializedSnapshot()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since 1.7.0 - Use snapshotFile() instead.
        The contents of the persisted snapshot file.
        Returns:
        The serialized snapshot.
      • snapshotFile

        public SnapshotFile snapshotFile()
        The contents of the persisted snapshot file. Note that the file's content and the value of serializedActual() can be different, even though the snapshot test did not fail. For example they could differ in whitespaces if whitespaces were ignored during comparison. Or they can differ in certain attributes if you used structure compare with custom comparison rules.
        Returns:
        The snapshot file.
      • serializedActual

        @API(status=EXPERIMENTAL,
             since="1.7.0")
        public java.lang.String serializedActual()
        Returns the serialized string value of the actual test input. Note that this value can be different from the contents of snapshotFile() (see the method's documentation for details).

        Note that this value can be a placeholder in case you passed a null value into SnapshotDsl.ChooseActual.assertThat(Object). Unless you called SnapshotDsl.ChooseAssertions.disabled(), passing a null value into a snapshot test would fail the test anyway.

        Returns:
        The serialized actual value.
        Since:
        1.7.0
      • failure

        public java.util.Optional<java.lang.Throwable> failure()
        The exception with which the snapshot assertion failed if any.
        Returns:
        The failure.
      • deleteSnapshot

        @Deprecated(since="1.8.0",
                    forRemoval=true)
        @API(status=DEPRECATED,
             since="1.8.0")
        public void deleteSnapshot()
                            throws java.io.IOException
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since 1.8.0 - Use contextFiles() with ContextFiles.deleteFiles() instead.
        Deletes the snapshot file and all accompanying context files.
        Throws:
        java.io.IOException - if an I/O error occurs
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object