简体   繁体   中英

Installing nUnit with ASP.Net MVC 1.0

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 :)

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 :).

I have posted a guide and a update to Joe Cartano post on this, so that it works with MVC 2.0.

http://www.dalsoft.co.uk/blog/index.php/2009/11/17/nunit-templates-for-asp-net-mvc-2-0-preview-2/

ScottGu just released some updated NUnit templates for ASP.NET MVC 1.0 . All you need to do is run the enclosed installNUnit.cmd file.

Have you tried just creating your own test project (with a reference to the MVC web app project) and manually adding the references you need to? I did this because trying to have VS.Net try to create the test project for me never worked out all that well (then again, I was doing it before preview 3). It's a minor PITA since I have to add using statements to every class I create in my test project, but it works. No command prompts, no registry, none of that nonsense needed.

As an aside, MvcContrib 's test helpers are a godsend.

我安装Xunit还没有足够使用它但它安装得很好我必须每次referance System.Routid和system.Web.Abstrations

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM