Monday, February 6, 2012

NCrunch, The Incredible TDD Tool!

I've been meaning to evaluate and review some development tools since forever. I think I waited so long just because I never found a tool that grabbed my attention to a level where it could really get me on my butt and make me jot down a review. Well, now we have such an awesomized tool - NCrunch!



Calling NCrunch just another TDD tool would be terrible injustice to it's developers.

NCrunch is -
  • An automated parallel continuous testing tool for Visual Studio.
  • A code coverage analyzer
  • A performance analyzer
  • And last, but not the least, incredibly smart!
Think about the usual steps you go through with test driven development:
  • Write test
  • Build and run tests
  • Write code
  • Build and run tests
  • Refactor code
  • Build and run tests
As a highly optimised test runner, NCrunch can knock half of these steps away by automating them completely - so you end up with:
  • Write test
  • Write code
  • Refactor code
Yes! The tests are automatically built and run in the background. Continuous feedback is provided on the fly, thereby making test development easier. As soon as the tests are build-able, NCrunch runs the tests and provides immediate feedback. Writing assertions is a pleasure!

And there's much more apart from this main feature. But, let's look at how a developer would use NCrunch. Here, we have written a simple test.


The view above shows the normal view that a developer shall have when NCrunch is disabled. Go ahead and enable NCrunch. Go to NCrunch -> Enable NCrunch. And now you see your editor shows something like this. Note that we have defined a default implementation for the Add() method that returns zero.


We shall go back and fix the method Add(). Also, you don't even need to save your files for NCrunch to be able to run your tests!


We now add another test to our suite.


While writing the test however, we see an error. This is because the test is wrong! Correct the test! I just love this level of immediate feedback! Hover over the red cross mark and it shows you a tooltip that tells you exactly what went wrong. (Click on image to view)


Fix the failing test and everything shows green again! NCrunch also handles exceptions gracefully and the tooltips indicate which exception occurred and where.

Code Coverage
The lines of code marked green indicate the parts of code that are covered by tests. This makes it very easy to spot areas that have not been covered yet, write covering code or eliminating any dead code. The following tooltip on the test tells you that the test is covered by 1 passing test.



Performance metrics
NCrunch also provides information about performance metrics and hot-spots in the tested code, thereby allowing you to identify parts of code that might induce a performance problem in the long run. The previous figure shows you the execution time of the test. The next figure shows you that the method being tested is too slow.


The yellow marker indicates that the code is executing really slow and that you should take a look to see if that's normal.

What frameworks does NCrunch support?
Supported testing frameworks are:
  • NUnit
  • MS Test
  • Xunit
  • MbUnit
  • MSpec
Supported languages and .NET versions are:
  • C#
  • VB.NET
  • F#
  • .NET Framework v2.0 and above
  • Visual Studio 2008
  • Visual Studio 2010
  • Visual Studio 11 Developer Preview
Pricing?
I'm sure that there has been a huge level of effort that has gone into developing this tool. But, the software is free to be used as long as it is in beta. Let's hope that on release the developers will price it economically.

There's a lot of other stuff that NCrunch supports that would make your life a wee bit easier. Go check out the NCrunch blog for updates! I really hope that this tool becomes a standard in everyday development for most software development firms.

Have fun with NCrunch!

Links:
NCrunch main website - http://www.ncrunch.net/
NCrunch Download - http://www.ncrunch.net/download.htm
NCrunch on Visual Studio Code Gallery - http://visualstudiogallery.msdn.microsoft.com/6946579c-c7d9-48ce-b039-994d30b85116

2 comments:

  1. Does it work with Microsoft Code Contracts?

    ReplyDelete
  2. humn, Its Real TDD! very very crunchy! :)

    ReplyDelete