Asp – Installing nUnit with ASP.Net MVC 1.0

asp.netasp.net-mvcnunitunit testingvisual-studio-2008

Does anyone have any advice/information on how to install nUnit with ASP.Net MVC? I have seen previous posts which related to the preview releases and involved a ghoulish nightmare of having to create template files, run command prompt and even mess with the registry.

Obviously this is far from ideal and given Microsoft's intention to allow any testing framework I was hoping that it was a much improved process in the full release. Googling seems to return results from when MVC was in the preview stage though! This is for Visual Studio 2008 Pro.

Cheers 🙂

Edit: Seems maybe not: http://msdn.microsoft.com/en-us/library/dd381614.aspx

Edit 2:: Ok found this: http://blogs.msdn.com/webdevtools/archive/2008/05/30/asp-net-mvc-preview-3-tooling-updates.aspx – They offer some templates and after installing the batch file it appears to show up in the drop down list when adding a new MVC application. However it was designed for the preview release of MVC so it's not ideal. Again, anyone who has better advice please post 🙂

Best Answer

Download it here and follow the steps in the read me file to install it.

Here's the overview of how I did it.

  1. Unzip the MVC test project template that comes with visual studio, MvcWebApplicationTestProjectTemplatev1.cs.zip.
  2. Changed HomeController.cs and AccountController.cs files to the NUnit syntax, such as, [TestClass] to [TestFixture], etc....
  3. Updated the references in MvcApplicationTest.csproj to for NUnit.Framework.
  4. Tweaked the MvcWebApplicationTestProjectTemplate.cs.vstemplate file changing NamePackage, Description, Icon Package, and Defaut Name.

Once you get it zipped back up you will need to open up the Visual Studio Command Prompt and type devenv /setup to register the template with visual studio.

You will need to create a registry entry so visual studio knows where the new template lives.

If I ever get a blog I will be happy to update my answer with a detailed post. It's a little involved to put it here...Goolish ain't the word :).