Unit testing assertions are now easier than ever with Verify Snapshot tool

Recently I had an opportunity to write some unit test cases for one of our .NET Core API application. With unit tests, we make assertions of how we expect our website or APIs to behave in a production-like environment. With the Verify Snapshot tool, unit testing assertions are now easier than ever! So, I thought to create one video on it rather than writing blog post.

In this video / article, I am going to introduce you with very interesting tool for unit testing named – Verify. It is an open-source tool developed by Simon Crop and as I said, this tool is very interesting because of the concept it tries to tackle. Verify is a snapshot tool that simplify the assertion in unit testing. Actually, it generates the snapshot of the test result during the assertion phase. So, let’s say – you have one data repository method. Now what Verify will do is – first it will capture a JSON representation of the result and store it into a snapshot file. Then you will need to check the result in that file and if the result looks good then you need to save that file. Now every time that test runs again the output of the test is compared to that original snapshot file. If everything is the same, then test will pass. If not, the test will fail.

Now, let’s see the below video of what I am saying.

Reference:

https://github.com/VerifyTests/Verify

I really appreciate your time and I hope you will like the above video.

Happy Learning.