Do You NCrunch Yet?
If you haven’t heard of NCrunch, you are in for a great surprise. Over the past few years, a friend and colleague of mine, Remco Mulder, has been slaving away on NCrunch. What is NCrunch? In my opinion, it is the most powerful Visual Studio plugin available. It is designed to help developers with TDD and automated testing in general. The plug-in runs automated tests in the background while a developer writes code, and shows code coverage inline in real time as this code is written.
You may be wondering if you read that correctly. Does NCrunch run your tests while you are writing code? Yes it does. NCrunch sandboxes the entire process of building, executing and testing a transient snapshot of a .NET solution – without a developer even needing to save their code to the hard disk. Feedback and code coverage from the tests is presented tidily and unobtrusively alongside the source code with any thrown exceptions or test failures shown inline. Let’s have a look at a snapshot of one of my projects in VS 2010 (with NCrunch).
Notice the green dots on the left hand side. They tell me that the line of code next to it is covered by at least one test and all of the tests covering that line are passing. If it wasn’t covered, the dot would be black. Let’s see what it would look like for a failing test. I am going to change the last line in IncrementIndex() to decrement the index by one instead of increment it. Have a look:
As you can see, NCrunch is now letting me know that all the lines of code with red dots are covered by failing tests. By the way, all I did was to replace the “+” with a “-“. I did not compile, or even save my change.
I have some options now. If I click on a red dot, the following context menu shows up:
From here, I can see the tests that are covering the line. I can navigate to the specific tests by simply clicking on it in this menu.
If I right click on a red dot, the following menu shows up for me:
As you can see, I can run the tests that are covering the code (if I don’t believe NCrunch), I can choose to ignore any failing tests (shame on me) or I can pin them to the tests window.
Why use NCrunch?
Some of you, like me, practice TDD. Others may not. However, all of you should be writing automated tests! NCrunch helps both groups. Before I started using NCrunch, I never realized how disruptive running my unit tests was. It was just a way of life. Write a test… Stop… Run my test… Stop… Write Code to make test pass… Stop… Run my test… Refactor… Repeat… Now, I almost never run my unit tests manually. They are always running behind the scenes. I don’t need to stop developing and do a mental context shift. I’m guessing that this saves me at least an hour of productivity a day.
The other beauty of NCrunch is the real-time feedback you get. First of all, it is very apparent where you have holes in your test coverage. Secondly, you know immediately if the code you are writing broke any tests. The nice thing is that you get this feedback when you are most prepared to address the issue. The code is fresh in your mind (you just wrote it)
Where do you get it and how much?
You can download NCrunch at www.ncrunch.net. Right now, it is in a beta state and Remco has decided to make it freely available in exchange for feedback from the .NET community. Good luck and get NCrunching.

Email Me