Your official information source from the .NET Web Development and Tools group at Microsoft.
ASP.Net MVC 1.0 RTM has been out for a while and I noticed that people are still downloading an NUnit sample project I created for ASP.Net MVC Preview 3. Since then an AccountController class and a corresponding set of unit tests have been added to the MVC Application project. I created an updated set of NUnit templates with tests for the Home and Account controllers. To install the templates, just extract the zip file from the link below and run installNUnit.cmd. VWD Express is supported along with VSTS as well as support for x86 and x64 bit OS's. If you are installing on Vista or higher, run the cmd file as an admin.
NUnit Test Templates
Below is a screenshot of the NUnit AccountControllerTest class for Visual Basic. If you build a new MVC project with NUnit selected as the test framework and run the test project dll in NUnit, you will see all the tests pass.
Hope this helps you unit test your MVC Apps!
Joe Cartano | Visual Web Developer
【原文地址】 May 30th Links: ASP.NET, AJAX, ASP.NET MVC, Visual Studio 【原文发表日期】 Saturday, May 30, 2009 3:39
I am not sure how that happened, here is the reg info, I'll try this out on Win7 x64 to see if I can find what the problem might be:
Windows Registry Editor Version 5.00
Вот последняя статья из моей серии списка ссылок . Также обратитесь к моим страничкам Советы, секреты
Error with Vista X64 and VS 2008 Express, looks like there is an issue what a path. This is what I get when I try to execute installNUnit.cmd (as Administrator):
\Microsoft was unexpected at this time.
c:\NUnitRTM> Set DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\VWDExpress
I was running the installNUnit.cmd from the VS2005 command shell. THat makes it choose wrong DevEnvDir (i.e. it chooses VS2005 as the IDE rather than the VWD). Running the script from regular cmd prompt solved the problem.
There are much longer more detailed ways involving editing the registry, running "devenv ..." command
Does this template is still valid with the ASP.NET MVC 1.0 release ?
I am having no luck getting this installed on Windows XP and Visual Studio 2008 Standard. I downloaded and installed NUnit 2.5.1. Then I ran NUnit Test Template installer above. Then I rebooted, opened Visual Studio 2008, created a new MVC Project, and no unit test dialog appeared. No errors appeared during any installation.
Anyone have any ideas? It doesn't seem like it should be this hard.
Apparently, if you don't have a Test directory present in
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp and VisualBasic
...it won't properly copy the zip file (just creates a Test file with nothing in it and no extension).
I hope this saves someone else a lot of frustration.
Thank you for pointing this out. I just uploaded a fix for this issue so that the test directory will be created if it does not exist already. I was doing this for Express but now I do this for all skus. If anybody else has trouble with installing on the STD sku, feel free to ping me at joecar at microsoft dot com.
Installed this and I can make a test project, but it seems to have a faulty link to 'nunit.framework' (there is a yellow exclamation mark warning sign next to it). I have NUnit installed, but perhaps not in the directory expected by these templates? Where is it supposed to be?
So after some investigation, I appear to have fixed this. I had the newest version of NUnit downloaded, and searched for 'nunit' in the project definition, and found this:
<Reference Include="nunit.framework, Version=188.8.131.52, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
I replaced this with an analogous nunit reference in a project in which I had set up the reference myself:
<Reference Include="nunit.framework, Version=184.108.40.20689, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
I had to replace the references in the template directory as well as the template cache directory (this was key). The question being is whether or not I have to change the reference again every time I upgrade nunit versions. Would changing the reference declaration to something like
<Reference Include="nunit.framework />
work as well?