Class SnapshotUtils
java.lang.Object
pro.verron.asciidoc.compiler.SnapshotUtils
Utility for snapshot testing.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertSnapshotMatch(Path actualPath, Path goldenPath, double tolerance) Asserts that the actual image matches the expected golden image.static doublecalculateDifference(BufferedImage img1, BufferedImage img2) Calculates the difference between two images. 0.0 means identical, 1.0 means completely different.
-
Method Details
-
assertSnapshotMatch
public static void assertSnapshotMatch(Path actualPath, Path goldenPath, double tolerance) throws IOException Asserts that the actual image matches the expected golden image. If the golden image doesn't exist, it creates it (useful for first run).- Parameters:
actualPath- path to the generated imagegoldenPath- path to the golden imagetolerance- maximum allowed difference (0.0 to 1.0)- Throws:
IOException- if an I/O error occursAssertionError- if images don't match
-
calculateDifference
Calculates the difference between two images. 0.0 means identical, 1.0 means completely different.- Parameters:
img1- first image to be comparedimg2- second image to be compared- Returns:
- The difference between the two images
-