Package de.skuzzle.test.snapshots
Interface SnapshotDsl.ChooseAssertions
-
- All Known Subinterfaces:
SnapshotDsl.ChooseStructure
- Enclosing interface:
- SnapshotDsl
@API(status=STABLE) public static interface SnapshotDsl.ChooseAssertionsDSL stage to choose how to perform the snapshot assertion.- Author:
- Simon Taddiken
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description SnapshotTestResultdisabled()Deprecated.This method is NOT deprecated.SnapshotTestResultjustUpdateSnapshot()Deprecated.This method is NOT deprecated.SnapshotTestResultmatchesAccordingTo(StructuralAssertions structuralAssertions)Asserts that the serialized actual test result structurally matches the persisted snapshot.SnapshotTestResultmatchesSnapshotText()Asserts that the serialized actual test result matches the persisted snapshot using a generic String diff algorithm.
-
-
-
Method Detail
-
justUpdateSnapshot
@Deprecated SnapshotTestResult justUpdateSnapshot()
Deprecated.This method is NOT deprecated. Deprecation serves only to mark this method in your IDE as it should only be used temporarily.This method just updates the persisted snapshot with the current actual test result. It will always make the test fail with an assertion failure. Use it only temporarily as replacement formatchesSnapshotText(),matchesAccordingTo(StructuralAssertions)orSnapshotDsl.ChooseStructure.matchesSnapshotStructure()- Returns:
- Details about the snapshot.
- Throws:
AssertionError- Always thrown by this method to indicate that a call to this method must be removed to enable snapshot assertions.- See Also:
ForceUpdateSnapshots
-
disabled
@API(status=EXPERIMENTAL, since="1.5.0") @Deprecated SnapshotTestResult disabled()Deprecated.This method is NOT deprecated. Deprecation serves only to mark this method in your IDE as it should only be used temporarily.This is a terminal DSL operation which just advances the internal state of the injected Snapshot instance but which does not apply any comparisons. This method is useful if you have multiple assertions within a single test case and you want to temporarily one. If you rely on automatic snapshot naming, subsequent assertions will still work as expected when using this method as opposed to just commenting out the assertion.When a DSL statement is terminated with this operation and no persisted snapshot file exists, none will be created. However the actual test result will still be serialized. Thus it is still possible to inspect the serialized result within the return
SnapshotTestResultobject. However, the referenced snapshot file will not exist in such cases.If a snapshot file already exists, it will not be reported as orphan file as long as the assertion is disabled.
Note: We can not make the same guarantees about orphan detection when using JUnit5's native mechanism for disabling tests. In such cases, we try to make a best effort guess based on statically available information.
- Returns:
- Details about the snapshot. Note that the reference snapshot file might not necessarily exist.
- Since:
- 1.5.0
-
matchesSnapshotText
SnapshotTestResult matchesSnapshotText()
Asserts that the serialized actual test result matches the persisted snapshot using a generic String diff algorithm. As this assertions only does a String comparison it can be used regardless whichSnapshotSerializerhas been used.- Returns:
- Details about the snapshot.
- Throws:
AssertionError- If the serialized objects do not match.- See Also:
TextSnapshot
-
matchesAccordingTo
SnapshotTestResult matchesAccordingTo(StructuralAssertions structuralAssertions)
Asserts that the serialized actual test result structurally matches the persisted snapshot. This method delegates to givenStructuralAssertionsinstance.- Parameters:
structuralAssertions- TheStructuralAssertionsinstance to use.- Returns:
- Details about the snapshot.
- Throws:
AssertionError- If the serialized objects do not match according toStructuralAssertions.assertEquals(String, String).
-
-