Simplify Unit testing with Beyond Compare

Consider the following NullValueHandlingBlogPost unit test from Json.Net.

image

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.

image

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.

image

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:

image

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.

image

Checkout the BeyondCompare class’s source here.

Advertisements

One thought on “Simplify Unit testing with Beyond Compare

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s