2

I ran into a problem with using WpfApprovals on different versions of the OS. My personal laptop is running Windows 7 Enterprise and the build server is running Windows 7 professional. Since the WpfApprovals is using the OS name in the approval file name, the tests are failing on the build server.

I tried a number of options to try to avoid including the OS in the approval name, however, it looks like this behavior is hard coded in WpfApprovals.cs...

    public static void Verify(Control control)
    {
        ApprovalResults.UniqueForOs();
        ApprovalTests.Approvals.Verify(new ImageWriter(f => WpfUtils.ScreenCapture(control, f)));
    }

... short of creating a modified version of the library that comments out the ApprovalResults.UniqueForOs() call, is there a way to disable including OS info in the approval file name?

While I can appreciate that these tests will fail with different major os versions, they shouldn't fail accross different editions. I noticed that the standard string verifier doesn't force the UniqueForOs style naming.

user3006539
  • 101
  • 1
  • 3

1 Answers1

2

Good point.

This Wpf is a bit tricky because the consistency is always an issue, but forcing it might not be the best idea, especially with no way to override the default behavior. While we figure out the correct solution for the next version, here are a couple of workarounds for 3.0.5

1) Copy file
You can just copy the approved file over to match both OS versions. This sucks a bit but involves no coding.

2) Customized Wpf call
While you stated not doing this it is a pretty easy fix

public static void Verify(Control control)
{
    ApprovalTests.Approvals.Verify(new ImageWriter(f => WpfUtils.ScreenCapture(control, f)));
}

Unfortunately this is it. There is not way to intercept the namer.

Thanks for bring this to our attention!

llewellyn falco
  • 2,281
  • 16
  • 13