I have created a package that outputs images, and now I want to create a bunch of tests for the package. I know, the tests should have been created much earlier, and not when I am almost done with the package, but it is what it is
So, my question is : How do you create tests when the output are images? Sure, I can compare the bytes of a stored correct image and the output image, and if they match, everything is ok.
But, according to my initial testing, every newly created image (in my case PNG:s) is different from the previously created image. It looks like there is A LOT of changes in the files, not just meta data, like created date etc, when I compare the images with meld. The images are visually identical though, and that is what I want to test, the visual part.
To me, it sounds like this must be a problem that other people have had? So how do you create tests for image outputs?
Hi @Hultan, how are you?
I have migrated a service from Java to Go converting images in different formats.
To compare the results, we made an small script that gets and image from both services and compare them.
Here are some tecniques:
Interesting, I think though, that in my case I only need to check for exact matches. So then it should be faster to just compare bytes by bytes, I think, rather that doing a bunch of math on each pixel.
I don’t need to know if it is close, it should be a match or not.
Sure, BUT if you change anything in your code, you should change all the tests.
You can’t upgrade your component that generate the images, for example.