Published on
Last Updated on
Estimated Reading Time: 1 min
I created Codinators.XunitHelpers(a NuGet package) to add some useful unit testing functionality that is missing in xUnit.
This release adds an auto approver to automatically update the approval files generated by ApprovalTests.Net.
Motivation
We use approval tests for a few scenarios over at FirstAml. Unfortunately, a small typo or a missing dependency registration can result in a lot of failed tests. Not only in this scenario but if we are using theory tests with Approval files and have it set up to use a _ DiffReporter_, a bunch of windows will open up if the tests fail. We then have to update the approval file and then close the diff window or reject the approval file and close all the windows.
This can be quite annoying and a big time-sink.
The AutoApprover automatically updates the approval files for any failed tests without opening any other windows.
Installation
Install it by using the following command
dotnet add package Codinators.XunitHelpers
Usage
In ApprovalTestConfig.cs
add the following snippet
using xUnitHelpers;
[assembly: UseReporter(typeof(AutoApprover))]
Result
It will automatically update the approval file. But in the test runner, it will show up as a failing test so that we have a clear indication of which tests failed.
It will not do anything if the received and approved files match so if we run the test again (without changing anything) , it will pass.