Continuous Testing with NCrunch

Disclaimer: I currently do not own or have been given a license to NCrunch. I am forming my opinions of it based on the use of the 30 day evaluation license.

In this article I want to talk about a very useful tool called NCrunch. I have had a few people recommend the tool to me recently, so I thought I would check it out. I am glad I did. So, what is NCrunch? The description on their site explains this nicely.

Continuous Testing with NCrunch

Continuous Testing with NCrunch

NCrunch is an automated concurrent testing tool for Visual Studio .NET. It intelligently runs automated tests so that you don’t have to, and gives you a huge amount of useful information about your tested code, such as code coverage and performance metrics, inline in your IDE while you type.

On reading that I first though, hmm, well doesn’t visual studios test explorer do that, and it does, but this tools goes a step further. In essence NCrunch executes tests in the background whilst you work giving you continuous feedback. Initially I thought that’s not really such a big deal. One of the projects I am working in has 690 unit tests and because they are true unit tests, as in they don’t hit databases or external resources, then they only take 20 seconds or so to run. Even though this is the case you still get into the compile, run the tests, check the results, fix or carry on loop.

What NCrunch does is concurrently run the tests as you write your code and if there are any tests that fail you are notified straight away. If that wasn’t cool enough though, NCrunch goes further. It gives you a near real time view of code coverage in your code window as you work. This is very useful indeed, if you are like me and a stickler for decent code coverage.

Once you have installed NCrunch and you enable it for a project you are taken through a configuration wizard.

Continuous Testing with NCrunch

Continuous Testing with NCrunch

This wizard lets you set up the amount of background threads, whether you want to run the tests linearly or in concurrent batches etc. This gives you a lot of flexibility to customize the running of the tests to suit your system and its specs. I have it set to run as 2 background threads and execute the tests concurrently. Interestingly when I first set this up, I had some intermittent test failures between 4 tests out of 698 tests because the way I had set up some test data made the tests order dependent, oops, that was quickly fixed though.

Continuous Testing with NCrunch

Continuous Testing with NCrunch

Once NCrunch is configured you can look at the NCrunch Tests window. This is similar to the standard Visual Studio 2012 Test Explorer in that it can show you all available tests and whether they have passed or failed. I find a more convenient way to configure it is to set it to only show failing tests because they are constantly being executed so you only want to know when they fail.

Continuous Testing with NCrunch

Continuous Testing with NCrunch

NCrunch also gives you a more immediate Risk/Progress view so that you can see very quickly at a glance if tests have failed. I like to have this and the test view docked to the left of the Visual Studio screen under my solution explorer. This works out very well on a large monitor, 24” in my case.

Continuous Testing with NCrunch

Continuous Testing with NCrunch

The other main killer feature of NCrunch is the code coverage feedback. In your source code windows you will see a series of coloured circles to the left of the screen. If the circle is green then that line of code is covered in tests. If it is black, then that line is not covered.

If you left click on one of the green circles you will see a list of all the tests that cover that line. If you right click on the circle, then you will be presented with options to run/debug the tests that affect that line. This immediate feedback is very useful indeed and helps you spot uncovered areas whilst the code is fresh in your mind.

NCrunch controls recompiling your project as you work, so you don’t have to keep on hitting recompile yourself. They have spent a lot of time making the compilation process very fast and smooth.

Conclusion

I must say this tool is very useful indeed. I am currently using the trial version and it has made a huge difference to the efficiency of my daily programming workflow. This tool is all about giving you rapid feedback whilst you work and it does that very well.

Apparently this tool used to be free of charge. I have heard a few people grumble about the fact you have to pay for it now. I can’t say I am that surprised that it is now a commercial tool. It genuinely is very useful, and sometimes this costs. At the time of writing, NCrunch will cost you $159 (£102) for a single user named license. There are difference licensing options available for companies.

I am seriously considering purchasing this tool when my trial expires; I think it really makes a difference to your workflow if you write decent unit tests. If you are more the type who writes integration tests posing as unit tests then you may struggle more with this tool as you will be having tests in the background trying to access databases and file systems, and if this isn’t managed properly you will hit all sorts of issues with the order in which your tests are executed.

Participate with Coding in the Trenches on Facebook

Participate with Coding in the Trenches on Facebook by Click the button above.

5 thoughts on “Continuous Testing with NCrunch

  1. Stephen Haunts Post author

    As a PS to my original post, I like this tool so much, that now my trial has expired I have just purchased myself a personal license.

    Reply
  2. Pinkham Software

    Love it! Totally eliminates the need to build then test, even works well on an Intel Dual Core (5 years old CPU). Only downside I’ve found so far is that you can forget to build your project when using it, and commit without updated proj files.

    Reply
  3. Pingback: Top 10 Tools That Have Changed the Way I Work | Stephen Haunts { Coding in the Trenches }

  4. Pingback: How to Motivate and Innovate Part 2 | Stephen Haunts { Coding in the Trenches }

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s