A image reporter to be used with ApprovalTests.Net
ApprovalTest has several built-in bindings to reporters you can use. One of them which is very nice is Perforce P4Merge. But for me it has several limitations, the foremost is that there is no way to approve an image.
This library uses Magick.NET (a .net wrapper for ImageMagick) for showing the diffrences between the images.
Just add [UseReporter(typeof(IMImageReporter)]
attribute on the test class or test method. See the AprrovalTests documentation
Install-Package ImageMagickApprovalReporter
[TestClass, UseReporter(typeof(IMImageReporter))]
public class ImageReporterTests
{
[TestMethod]
public void TestImage()
{
string filePath=@"c:\myFile.png";
SUT.DoSomthingToFile(filePath);
Approvals.VerifyFile(filePath);
}
}
At first, there is nothing to compare to, so just approve it if it is the right file
Compare using the outline method
Compare using the absolute method
When the image attributes are different, the differences are highlighted
If you are good at ImageMagick and can make the Comparsions better, please help.