Snapshot Testing for AsciiDoc Previews
The asciidoc-compiler module uses snapshot testing to ensure the visual consistency of generated previews.
Snapshots are compared against "golden" images stored in the repository.
How it Works
- Test Execution: When
AsciiDocSnapshotTestruns, it generates PNG images from sample AsciiDoc files. - Comparison: The generated images are compared pixel-by-pixel with the golden images in
src/test/resources/golden. - Tolerance: A small tolerance (e.g., 1%) is allowed to account for minor rendering differences across platforms.
- Failure: If the difference exceeds the tolerance, the test fails.
Updating Snapshots
If you intentionally change the rendering logic (e.g., changing a theme’s color or layout), the snapshots will fail. To update them:
- Delete the old golden images: Remove the files in
src/test/resources/golden/that you want to update. - Run the tests: Re-run
AsciiDocSnapshotTest. Since the golden images are missing, the test utility will automatically create new ones from the current output. - Verify the new images: Manually inspect the newly created golden images to ensure they look as expected.
- Commit: Commit the updated golden images to the repository.