Package de.skuzzle.test.snapshots
Class SnapshotTestResult
- java.lang.Object
-
- de.skuzzle.test.snapshots.SnapshotTestResult
-
@API(status=EXPERIMENTAL) public final class SnapshotTestResult extends java.lang.ObjectResult details of a single snapshot assertion. An instance of this class is returned by every DSL terminal operation.- Since:
- 0.0.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnapshotTestResult.SnapshotStatusInformation about the creation of a single snapshot file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.nio.file.PathactualResultFile()Deprecated, for removal: This API element is subject to removal in a future version.Since 1.8.0 - UsecontextFiles()withContextFiles.actualResultFile()instead.ContextFilescontextFiles()Returns a class that holds the paths to all generated files.voiddeleteSnapshot()Deprecated, for removal: This API element is subject to removal in a future version.Since 1.8.0 - UsecontextFiles()withContextFiles.deleteFiles()instead.java.util.Optional<java.lang.Throwable>failure()The exception with which the snapshot assertion failed if any.static SnapshotTestResultforFailedTest(ContextFiles contextFiles, SnapshotFile snapshotFile, java.lang.String serializedActual, java.lang.Throwable failure)static SnapshotTestResultof(ContextFiles contextFiles, SnapshotTestResult.SnapshotStatus status, SnapshotFile snapshotFile, java.lang.String serializedActual)java.nio.file.PathrawActualResultFile()Deprecated, for removal: This API element is subject to removal in a future version.Since 1.8.0 - UsecontextFiles()withContextFiles.snapshotFile()instead.java.lang.StringserializedActual()Returns the serialized string value of the actual test input.SnapshotFileserializedSnapshot()Deprecated, for removal: This API element is subject to removal in a future version.Since 1.7.0 - UsesnapshotFile()instead.SnapshotFilesnapshotFile()The contents of the persisted snapshot file.SnapshotTestResult.SnapshotStatusstatus()Whether snapshot has been created/updated or asserted.java.nio.file.PathtargetFile()Deprecated, for removal: This API element is subject to removal in a future version.Since 1.8.0 - UsecontextFiles()withContextFiles.snapshotFile()instead.java.lang.StringtoString()
-
-
-
Method Detail
-
forFailedTest
@API(status=INTERNAL) public static SnapshotTestResult forFailedTest(ContextFiles contextFiles, SnapshotFile snapshotFile, java.lang.String serializedActual, java.lang.Throwable failure)
-
of
@API(status=INTERNAL) public static SnapshotTestResult of(ContextFiles contextFiles, SnapshotTestResult.SnapshotStatus status, SnapshotFile snapshotFile, java.lang.String serializedActual)
-
contextFiles
@API(status=EXPERIMENTAL, since="1.8.0") public ContextFiles contextFiles()Returns a class that holds the paths to all generated files.- Returns:
- The context files.
- See Also:
SnapshotTestOptions.alwaysPersistActualResult(),SnapshotTestOptions.alwaysPersistRawResult()
-
targetFile
@Deprecated(since="1.8.0", forRemoval=true) @API(status=DEPRECATED, since="1.8.0") public java.nio.file.Path targetFile()Deprecated, for removal: This API element is subject to removal in a future version.Since 1.8.0 - UsecontextFiles()withContextFiles.snapshotFile()instead.The snapshot file. Note that it is possible that the file does not exist in case thatstatus()isSnapshotTestResult.SnapshotStatus.DISABLED.- Returns:
- The snapshot file.
- See Also:
actualResultFile(),rawActualResultFile()
-
actualResultFile
@Deprecated(since="1.8.0", forRemoval=true) @API(status=DEPRECATED, since="1.8.0") public java.nio.file.Path actualResultFile()Deprecated, for removal: This API element is subject to removal in a future version.Since 1.8.0 - UsecontextFiles()withContextFiles.actualResultFile()instead.Path to the file in which the latest actual result will be stored. The file will only exist if the recent snapshot assertion was executed withSnapshotTestOptions.alwaysPersistActualResult()being true.- Returns:
- The path to the file with the latest actual result file.
- Since:
- 1.7.0
- See Also:
targetFile(),rawActualResultFile(),SnapshotTestOptions.alwaysPersistActualResult()
-
rawActualResultFile
@Deprecated(since="1.8.0", forRemoval=true) @API(status=DEPRECATED, since="1.8.0") public java.nio.file.Path rawActualResultFile()Deprecated, for removal: This API element is subject to removal in a future version.Since 1.8.0 - UsecontextFiles()withContextFiles.snapshotFile()instead.Path to the file in which the latest raw actual result will be stored (without the snapshot header). The file will only exist if the recent snapshot assertion was executed withSnapshotTestOptions.alwaysPersistRawResult()being true.- Returns:
- The path to the file with the latest raw actual result file.
- Since:
- 1.7.0
- See Also:
targetFile(),actualResultFile(),SnapshotTestOptions.alwaysPersistRawResult()
-
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 - UsesnapshotFile()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 ofserializedActual()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 ofsnapshotFile()(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 calledSnapshotDsl.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.IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since 1.8.0 - UsecontextFiles()withContextFiles.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:
toStringin classjava.lang.Object
-
-