Why is my Verify.Bunit test failing and not producing a received file?

224 views Asked by At

I am using the Verify.Xunit and Verify.Bunit packages in my test project but they have started failing and I can't figure out why.

Example simple test - just renders a component:

[Fact]
public Task TestInputBaseRendering_Default()
{
  //Arrange: render the base markup
  var cut = this.Render(TestInputBaseRendering_Default_Markup);

  // Act: 

  // Assert: 
  return Verify(cut);
}

The first time I run the test, it produces a received file and an empty verified file and launches my diff tool where I can copy the received text into the verified file and save - this is expected normal behaviour.

Sample output now saved as TestInputBaseRendering_Default.verified.html:

<input type="text" autocomplete="off" name="" id="id1" blazor:onchange="1" blazor:elementreference="Guid_1">

When I then re-run the test it should produce the same output (debugging and inspecting the object being passed to Verify(cut) shows the correct output) - save it in TestInputBaseRendering_Default.received.html and compare this to TestInputBaseRendering_Default.verified.html

If there was a difference, it should launch my diff tool to inspect the variance in output.

What is actually happening is the test fails again does not open the diff tool and does not save a received file:

Test result:

Message: 
VerifyException : Directory: C:\Users\xxxxx\source\repos\xxxxx\tests\xxxxx.test\Inputs\SBInputBaseTests
Delete:
  - InputBaseRenderingTests.TestInputBaseRendering_Label.verified.html.bak
  - InputBaseRenderingTests.TestInputBaseRendering_Label.verified.txt.bak
Equal:
  - Received: InputBaseRenderingTests.TestInputBaseRendering_Label.received.txt
    Verified: InputBaseRenderingTests.TestInputBaseRendering_Label.verified.txt
  - Received: InputBaseRenderingTests.TestInputBaseRendering_Label.received.html
    Verified: InputBaseRenderingTests.TestInputBaseRendering_Label.verified.html

I have no idea how to resolve that the test now fails every time and does not save the received file.

I have checked by debugging the test that the component is rendered correctly each time - the problem lies somewhere in the Verify system, for which I cannot find any additional logging or debugging help.

1

There are 1 answers

1
Simon On BEST ANSWER

it isnt launching a diff tool since the inputs match the verified files.

it is telling you that there are 2 unexpected files that should be deleted

  • InputBaseRenderingTests.TestInputBaseRendering_Label.verified.html.bak
  • InputBaseRenderingTests.TestInputBaseRendering_Label.verified.txt.bak

if u use diffenginetray (https://github.com/VerifyTests/DiffEngine/blob/main/docs/tray.md) it will automate this. or u can use one of the other approaches to managing snapshots

https://github.com/VerifyTests/Verify#snapshot-management

re winmerge

Ensure that file backups are either disabled or changed to use a Global backup folder