Search code examples
unit-testingxunitsnapshot-testing

When running a snapshot test with Verify an exception is thrown because the verified.txt.bak file is still there


I'm using Verify.Xunit (version 19.11.2) in a .NET 6 xUnit test project. Tests are running in the Rider IDE. To do the Verify actual/expected string comparison Verify uses WinMerge.

Sometimes (more often than not) when running a test the temporary verified.txt.bak file is still there. The test is complaining about the existence of this bak file.

VerifyException
Directory: C:\code\SnapshotTesting\SnapshotTesting
Delete:
  - UnitTest.CreateReport_ShouldBeAsExpected.verified.txt.bak
Equal:
  - Received: UnitTest.CreateReport_ShouldBeAsExpected.received.txt
    Verified: UnitTest.CreateReport_ShouldBeAsExpected.verified.txt

  Exception doesn't have a stacktrace

I would expect that cleaning up this bak file is not my task and be sone automatically so I was wondering what could cause this issue? After removing the bak file the test works as expected.


Solution

  • this is fixed in version 20.5.0 of verify