Consider the following NullValueHandlingBlogPost unit test from Json.Net.
Assume you are maintaining this test and once fine Friday evening at 6pm (they always break @ 6pm) you get an alert from build system that NullValueHandlingBlogPost failed.
Description don’t match, but, that’s not the only difference, ReleaseCounteries is also different, so once you fix Description and run the unit test again you will find out about ReleaseCounteries and you can go ahead and fix that too. This was a trivial case, spotting similar differences in a complex xml is a lot more headache.
What if, rather than NUnit output strings, you get the following BeyondCompare diff screen whenever the expected and actual string don’t match.
Now isn’t this so much better, here I am launching launch Beyond Comapre if the expected and actual text does not match in the unit test, like this:
In a single glance you can spot all the differences and get a better understanding of the bug causing the unit test to fail. This saved me a good couple of hours trying to fix a unit test involving large xml configuration file. You can use any diff tool that you like, here @ B-Line Medical we are BeyondCompare fan, so I used that. I added a couple of more methods to compare files and objects as well.
Checkout the BeyondCompare class’s source here.