ImageMagick 7+ must be installed and added to PATH variable
<dependency>
<groupId>com.github.annypatel.image-assert</groupId>
<artifactId>image-assert-im7</artifactId>
<version>1.0.6</version>
</dependency>
'com.github.annypatel.image-assert:image-assert-im7:1.0.6'
Approach and syntax are similar to FEST-Assert library. Use static method assertThat() to create ImageAssert instance. By default, ImageAssert instance does not report comparison results neither throws an exception, so you will need to provide one or multiple listeners using reportingTo() method.
You can create an ImageAssert instance and use chained calls to compare two images:
ImageAssert.assertThat(screenshot)
.reportingTo(ThrowExceptionResultListener())
.isEqualTo(resource);
Alternatively, you can create a method to return a pre-configured instance of ImageAssert:
ImageAssert assertThat(Image image) {
return ImageAssert.assertThat(image)
.reportingTo(PrintStreamResultListener())
.reportingTo(ThrowExceptionResultListener())
}
and then use it instead of static method (static methods are awful, right?):
assertThat(screenshot())
.isEqualTo(resource());