NCrunch: Unit testing, the right way?

4 September 2012, by

NCrunch is an automated parallel continuous testing tool for Visual Studio .NET. It intelligently takes responsibility for running automated tests so that you don’t have to, and it gives you a huge amount of useful information about your tests (such as code coverage) inline in your IDE while you work. Basically, it runs your unit tests for you, simplifying your workflow.

Here’s an example from a recent project. We have a unit test called TestUnitLinks, which is one of the three tests that use a value list.

Link Test

The green circles mean this test is currently passing.
If we look at ValueList.cs, we’ll see that the constructor is tested (and passed the test), but some of its lines aren’t covered.

Value List

Let’s break the value list a bit. Once we add an exception in there, we’ll see that the test failed almost immediately.

Value List
Link Test

You can also see how many tests test each line and navigate to them.

Value List

NCrunch takes over half of your cores by default, so should only be used with powerful computers. It doesn’t seem to slow down VS at all as the two never run on the same cores; it also only reruns tests which would be changed by your new code – i.e. when you changed lines which are or would be covered. So it’s pretty fast, and looks very useful. I haven’t tried anything more than what you see in here so I don’t know if it’s actually useful when working on projects, but to me it seems like it would be. You may never need to run your tests again!

Tags: , , , ,

Categories: Technical


Leave a Reply

* Mandatory fields

+ 9 = eleven

Submit Comment