Saturday, January 22, 2011

ASP.NET MVC 3 Project with NUnit as Testing framework

[UPDATE] Marcus has been able to make a new Visual Studio Extension that add NUnit as an option when selecting test framework for ASP.NET MVC 3. You can get that from Visual Studio gallery for free.

Don’t you sometimes have this feeling when you need something that Microsoft could make out of the box?

I got the same kind of idea today when I was trying to create a new ASP.NET MVC 3 website with NUnit as test framework. And I could find this page How to: Add a Custom ASP.NET MVC Test Framework in Visual Studio but the whole thing wasn’t very easy and it was indicated that you should insert some keys and values into registry.

“Man, I don’t like that”, I thought, “Isn’t there an easier solution which could make it all work ?”.

I googled a little bit, and I found this blog post: ASP.NET MVC 3 with NUnit Testproject written by Marcus Kimpenhaus. In the bottom of this blog post there is a link via which you can download and install the NUnit template for ASP.NET MVC 3, this template worked for x64 bit machines, but I left a comment and he was nice to update it for x86 machines too. Thanks very much Marcus this project template is invaluable when need it. I also suggested to publish this template to NuGet feed, and if this will work it would be great and you could install it directly from your NuGet console.

So let’s resume what do you need to do in order to have a NUnit Test project template for your ASP.NET MVC 3 project:

  1. At the bottom of the blog post click the download link for the project template
  2. Run install.bat as administrator, now this bat will check the type of your machine : x64 or x86 and will edit registry accordingly to that, it will also update your Visual Studio 2010 cache so please wait a little bit there
  3. Go and thank Marcus for his work, and send a mail to ASP.NET team to include this project template in the Visual Studio SP1. After all the SP1 is coming in spring so they still have lots of time to include it.

Hope this will help someone.

2 comments:

  1. Hey Timur,

    finally I managed to get the Visual Studio Extension ready and published on Visual Studio Gallery: ASP.NET MVC NUnit

    Beste wishes,
    Marcus

    ReplyDelete
  2. Dead links in article.

    ReplyDelete