Skip to content

Image comparison library for automated testing

License

Notifications You must be signed in to change notification settings

annypatel/image-assert

 
 

Repository files navigation

System requirements

ImageMagick 7+ must be installed and added to PATH variable

Dependencies

Maven
<dependency>
	<groupId>com.github.annypatel.image-assert</groupId>
	<artifactId>image-assert-im7</artifactId>
	<version>1.0.6</version>
</dependency>
Gradle
'com.github.annypatel.image-assert:image-assert-im7:1.0.6'

Usage

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.

Examples

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());

About

Image comparison library for automated testing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 95.3%
  • JavaScript 2.7%
  • CSS 1.1%
  • HTML 0.9%