1

Is it possible to compare two images with a mask for area's that do not need to be compared.

I managed to get it working with a basic file comparison

[UseReporter(typeof(BeyondCompareReporter))]
public void ThenThePageShouldMatchTheApprovedVersion()
{
    SaveScreenshot("page1");
    Approvals.VerifyFile(@"C:\page1.png");
}

But i would like to create a mask of the area's i expect to change. Is this possible with ApprovalTests or will i need to modify the screenshot and manually apply the mask before comparing with the approved file. Or is it possible to write your own validators?

Ryan B
  • 681
  • 7
  • 14

1 Answers1

1

It's not possible to mask the area so the comparer will not compare them.

However, it is very easy to actually mask the area (ie, place a black square over the area before you call Verify)

Alternatively, you can usually mock out the variable that is changing.

Details on Comparer: ApprovalsFileComparer is a very stupid comparer. It knows nothing about file formats and has no idea of what an image is. It simply compares byte to byte. This simplicity allows it to work everywhere, but removes the ability to be smart about stuff. This is usually not an issue as the reporters are very very smart. Able to render and compare and do subtractive diffs and the like.

Happy Testing!

llewellyn falco
  • 2,281
  • 16
  • 13
  • So its possible to write your own comparer? also is it the comparer that fails the test or the reporter? If its the comparer then a byte by byte comparison will not work unless i'm comparing an already masked version. – Ryan B Mar 04 '15 at 03:42