nCrunch review – TDD on steroids

Any project that uses unit tests gets to the stage where running all of the tests takes a lot of time. Even if you manage to keep your test suite in a manageable size From time to time a developer would “forget” to run all the tests before commit and break the build.

One solution for these problems is to have an automatic test runner/continuous testing tool that runs the tests automatically.

The idea of continuous testing has it’s roots in the Java world. JUnitMax which was create by Kent Beck, runs all of the tests on each save. The order of the tests is determined by risk – the first tests run were the ones that failed on the previous run. Although this solution does not solve long run times it does make sure that your code is constantly being verified.

In the .NET space there are several such tools one of which shine above the rest –  nCrunch.

Getting started

nCrunch is code coverage, test runner and performance analyzer all in one. Using it is simple – all you need to do is to choose to enable it and after filling a few options you’re ready to go.

You can choose how many CPU cores to dedicate to running of tests and whether or not you wish to run your tests in parallel. Another option is to run the test manually – in case you “only” wish to use nCrunch as a test runner.

Running nCrunch

After this short configuration nCrunch would automatically discover all of the unit test in your solution and try to run them. So far I’ve used it with NUnit, and XUnit and it worked perfectly. On each save the code is compiled, and tests are run . nCrunch can be configured to run only the tests affected by the last code change. I’ve used this option thus avoiding a long test run with each change I make.

Another plus is the continuous code coverage results, each line of code written is immediately marked as covered/not covered by unit tests and if that unit test(s) fail – it is also marked in red.

When a test fails nCrunch provide full exception information and an arsenal of debugging options to choose from – from simple “run in debug” to “Break into the first failing covering test at this line”.

Supercharge your unit tests

nCrunch is one of these tools I’ve been looking for without actually realizing it. Using it makes TDD (Test Drive Development) easy to follow. If you want an excellent example – take a look at this video (YouTube):

Around 1:10 it really gets interesting when the code is written and the tests are executed side by side


nCrunch is not the only continuous testing tool out there but it’s certainly the most mature one – with easy configuration and many useful features it’s the unit testing productivity tool that I was look for.

Leave a Reply

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

You are commenting using your 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