Class SnapshotUtils

java.lang.Object
pro.verron.asciidoc.compiler.SnapshotUtils

public final class SnapshotUtils extends Object
Utility for snapshot testing.
  • 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 image
      goldenPath - path to the golden image
      tolerance - maximum allowed difference (0.0 to 1.0)
      Throws:
      IOException - if an I/O error occurs
      AssertionError - if images don't match
    • calculateDifference

      public static double calculateDifference(BufferedImage img1, BufferedImage img2)
      Calculates the difference between two images. 0.0 means identical, 1.0 means completely different.
      Parameters:
      img1 - first image to be compared
      img2 - second image to be compared
      Returns:
      The difference between the two images