Skip to Navigation or
Skip to Content

Some Handy NCrunch Tips

Feeds

RSS Feed

<< November | December | January >>

Wednesday, 7th December 2011

I have spent a little time today setting up NCrunch for Visual Studio. NCrunch is a handy extension that runs all your tests (unit and integration) in the background while you code and reports any failures to you as they happen. It also shows you code coverage in the margin of your actual code files. This is awesome.

So once you have downloaded NCrunch, what do you do? Here are my top tips for a trouble-free first run.

Open up NCrunch options, from the NCrunch menu in the Visual Studio Toolbar. For all projects in your solution, set "CopyReferencedAssembliesToWorkspace" to true. This means that referenced projects will end up in the bin directory of the copy that NCrunch creates - this is important if you want stuff to run.

If you have signed assemblies and have used the dummy-file VS_KEY hack, you need to include your dummy VS_KEY files in your project so they get copied to the folder NCrunch uses to run the tests.

If something doesn't appear to be working, open up the NCrunch options and set "LogToOuputWindow" to true and "LogVerbosity" to medium.

The final tip is to make use of the NCrunch Environment Variable wherever you need to do something special for NCrunch. In my case, I'm using it to point NCrunch at a local database for integration tests.

return Environment.GetEnvironmentVariable("NCrunch") == "1" ?
    ConfigurationManager.AppSettings["ncrunchConnectionString"] :
    ConfigurationManager.AppSettings["dbConnectionString"];

These may seem like simple things, but knowing them now will save you a bit of time when you get started with NCrunch. I can't over-state just how excellent this extension is, especially for TDD teams.

 

You Are Here: Home » Blog » Some Handy NCrunch Tips

 

I use a cookie on this website. This cookie doesn't contain or relate to any personal information and it isn't shared with any other website, it just ensures that I don't count you more than once in my website statistics. The Privacy and Electronic Communications Regulations require me to ask your permission to use this cookie, so please indicate below that you are happy for me to do this - I will remember your selection with a cookie, so if you accept I won't ask again...