views:

265

answers:

1

I understand that the Express edition doesn't template unit test projects... but being a complete newbie to Microsoft dev tools, I can't figure out how to set up the necessary things manually either. So could someone please walk me through how to get NUnit going?

+1  A: 

It's actually quite simple:

  1. Download NUnit.
  2. Set up a new console application or class library in Visual Studio.
  3. Add a reference to the nunit.framework.
  4. Add a reference to the class library you want to test (put the code you want to test into a separate class library)
  5. Follow a tutorial on how to create your own tests.

See this link for a sample MVC 1.0 project and sample templates, or this link for MVC 2.0 templates.

Prutswonder
Ok. Does that work for a MVC web app?
Andrew McGregor
Sure. See this link for a sample project and some sample templates: http://blogs.msdn.com/webdevtools/archive/2009/04/28/updated-nunit-templates-for-asp-net-mvc-1-0-rtm.aspx
Prutswonder
Doesn't work for me... there's a clear reference to version 9.0 of some framework, and of course I'm using 2010, which is version 10.0. So there's an error when trying to instantiate the template. Any idea how to fix that?
Andrew McGregor
In that case, you can download the templates here: http://blogs.tnjconsulting.com/users/jason/weblog/eaabd/MVC_NUnit_Template_for_VS_2010.html
Prutswonder
Ok, now I'm baffled. I followed that process and nothing changed. The .reg file that came with those templates seems to be for Visual Studio non-Express, but I made the obvious changes, still nothing.
Andrew McGregor
This old question may have some tips for you: http://stackoverflow.com/questions/666941/how-do-i-add-nunit-as-a-test-framework-option-for-asp-net-mvc-to-visual-web-devel
Prutswonder
So, can you describe how to manually construct an MVC 2.0 NUnit test project? I'm happy to build stuff from source even. I don't understand precisely what you mean by point #4 above, either.
Andrew McGregor
Read the ASP.NET MVC Framework Unleashed book, which uses TDD to develop an MVC blog site. Although it uses VS Tests instead of NUnit, it is a great example of how you can develop your own tests. Source code is freely available. http://www.informit.com/store/product.aspx?isbn=0672329980
Prutswonder
http://stackoverflow.com/questions/666941/how-do-i-add-nunit-as-a-test-framework-option-for-asp-net-mvc-to-visual-web-devel had the answer... I had everything in place except the right registry magic.
Andrew McGregor
Ok, so it still isn't working... I don't get any test project materials unpacked.
Andrew McGregor