@API(status=STABLE)
Package de.skuzzle.test.snapshots
The main public snapshot-testing API.
Snapshot tests are enabled for a test class via
EnableSnapshotTests. This will allow you to inject an
instance of SnapshotDsl.Snapshot into any test method
within said test class.
@EnableSnapshotTests
class SomethingSomethingTest {
@Test
void test_to_string_representation(Snapshot snapshot) throws Exception {
Object actualTestResult = subject.codeUnterTest(...);
snapshot.assertThat(actualTestResult)
.asText()
.matchesSnapshotText();
}
@Test
void test_json_serialization(Snapshot snapshot) throws Exception {
Object actualTestResult = subject.codeUnterTest(...);
snapshot.assertThat(actualTestResult)
.as(XmlSnapshot.xml)
.matchesSnapshotStructure();
}
}
- See Also:
EnableSnapshotTests,SnapshotDsl.Snapshot
-
Interface Summary Interface Description ComparisonRuleBuilder Builder for customizing how snapshot files are compared against the actual test result.ComparisonRuleBuilder.ChooseMatcher Allows to choose the comparison for the value.Snapshot Allows to do snapshot assertions.SnapshotDirectoryStrategy Strategy interface which can be used to determine a custom snapshot directory.SnapshotDsl DSL for defining snapshot tests.SnapshotDsl.ChooseActual SnapshotDsl.ChooseAssertions DSL stage to choose how to perform the snapshot assertion.SnapshotDsl.ChooseDataFormat Allows to choose the structure into which the actual test result will be serialized.SnapshotDsl.ChooseDirectory SnapshotDsl.ChooseName SnapshotDsl.ChooseStructure SnapshotDsl.Snapshot Deprecated, for removal: This API element is subject to removal in a future version. Since 1.8.0 - Use the new top-level typeSnapshotinstead.SnapshotNaming Strategy interface for dynamically determining snapshot names.SnapshotSerializer Defines how an object is serialized into a persistable snapshot String.StructuralAssertions Allows to customize how structured data is compared in order to check whether a snapshot matches an actual test result.StructuredDataProvider Tagging interface for classes that can provide an instance ofStructuredData. -
Class Summary Class Description ContextFiles Holds the paths to all files that might have been generated by a single snapshot assertion.SnapshotFile A snapshot file is a plain text file containing a header and the actual serialized snapshot.SnapshotFile.SnapshotHeader SnapshotTestResult Result details of a single snapshot assertion.StructuredData Combines aSnapshotSerializerand aStructuralAssertionsinstance. -
Enum Summary Enum Description SnapshotTestOptions.DiffFormat Format of the diffs rendered in our assertion failures.SnapshotTestOptions.DiffLineNumbers Defines whether an offset is added to the line numbers when rendering diffs in assertion failure messages.SnapshotTestOptions.NormalizeLineEndings Defines how and if line endings will be normalized after snapshot serialization.SnapshotTestResult.SnapshotStatus Information about the creation of a single snapshot file. -
Exception Summary Exception Description SnapshotException This is a framework exception that can be thrown when implementing certain extension points. -
Annotation Types Summary Annotation Type Description DeleteOrphanedSnapshots Deprecated. This annotation is NOT deprecated.EnableSnapshotTests Deprecated, for removal: This API element is subject to removal in a future version. Since 1.7.0 - This class is deprecated in favor of theEnableSnapshotTestsclass within thejunit5package.ForceUpdateSnapshots Deprecated. This annotation is NOT deprecated.SnapshotDirectory Drop in replacement forEnableSnapshotTests.snapshotDirectory().SnapshotTestOptions Allows to configure some behavior details of the snapshot testing engine.