Package au.com.origin.snapshots.config
Interface SnapshotConfig
- All Known Implementing Classes:
PropertyResolvingSnapshotConfig
public interface SnapshotConfig
Snapshot Configuration ----------------------
Implement this interface when integrating `java-snapshot-testing` with a custom testing library
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionOptional Override to supply your own custom comparator functionThe base directory where files get written (excluding package directories) default: "src/test/java"Optional Override to supply your own custom reporter functions Reporters will run in the same sequence as provided.Optional Override to supply your own custom serialization functionSubdirectory to store snapshots inbooleanisCI()Optional This method is meant to detect if we're running on a CI environment.Optional
-
Field Details
-
JVM_UPDATE_SNAPSHOTS_PARAMETER
Deprecated.- See Also:
-
-
Method Details
-
getOutputDir
String getOutputDir()The base directory where files get written (excluding package directories) default: "src/test/java"You might want to override if you have tests under "src/test/integration" for example
- Returns:
- snapshot output folder
-
getSnapshotDir
String getSnapshotDir()Subdirectory to store snapshots in- Returns:
- name of subdirectory
-
updateSnapshot
Optional- Returns:
- snapshots should be updated automatically without verification
-
getSerializer
SnapshotSerializer getSerializer()Optional Override to supply your own custom serialization function- Returns:
- custom serialization function
-
getComparator
SnapshotComparator getComparator()Optional Override to supply your own custom comparator function- Returns:
- custom comparator function
-
getReporters
List<SnapshotReporter> getReporters()Optional Override to supply your own custom reporter functions Reporters will run in the same sequence as provided. Reporters should throw exceptions to indicate comparison failure. Exceptions thrown from reporters are aggregated and reported together. Reporters that wish to leverage IDE comparison tools can use standard assertion libraries like assertj, junit jupiter assertions (or) opentest4j.- Returns:
- custom reporter functions
-
isCI
boolean isCI()Optional This method is meant to detect if we're running on a CI environment. This is used to determine the action to be taken when a snapshot is not found.If this method returns false, meaning we're NOT running on a CI environment (probably a dev machine), a new snapshot is created when not found.
If this method returns true, meaning we're running on a CI environment, no new snapshots are created and an error is thrown instead to prevent tests from silently passing when snapshots are not found.
Often to determine if running on a CI environment is to check for the presence of a 'CI' env variable
- Returns:
- boolean indicating if we're running on a CI environment or not
-