19

According to Professional ASP.NET MVC 1.0, page 8, "If you are using VS 2008 Standard Edition or Visual Web Developer 2008 Express you will need to download and install the NUnit, MBUnit or XUnit extensions for ASP.NET MVC in order for [the Create Unit Test Project] dialog to be shown."

Is there such an extension available to download for NUnit 2.4.8? If so where can I download it from?

If not, how can I set it up? I looked at the ASP.Net MVC and nUnit question and the articles How to: Add a Custom MVC Test Framework in Visual Studio and ASP.NET MVC Test Framework Integration Walkthrough. But they all refer to running devenv /setup which doesn't seem to be available for Visual Web Developer 2008 Express. Has anyone gotten the Create Unit Test Project dialog working with NUnit and VWD Express? How so?

Thanks

Community
  • 1
  • 1
Mike Henry
  • 2,401
  • 1
  • 25
  • 34
  • I've added an "answer" to this question that is really more of an additional question. Ideally, it could be added into a second part of the original question (sadly, I do not have the rep yet to modify questions.) – Beska Mar 27 '09 at 19:11

9 Answers9

12

The easiest way now in 2011 is to install this ASP.NET MVC NUnit extension from the Visual Studio gallery. The nice part is that this extension can be updated over time so you will have the latest nunit mvc template.

bkaid
  • 51,465
  • 22
  • 112
  • 128
  • Worked great for me also, allows NUnit to be kept up to date really simply with NuGet. Once the extension is installed just right click the test project and select 'Manage NuGet Packages...' to update to latest NUnit. – Stuart Hallows Mar 16 '12 at 23:12
8

I just found this Updated NUnit Templates for ASP.Net MVC 1.0 RTM which includes a cmd file to setup the NUnit test framework templates for VWD Express.

Yay, no more manual steps (unless you really want to).

Mike Henry
  • 2,401
  • 1
  • 25
  • 34
  • Right on. This makes it trivial. Good job maintaining this one. – Beska Aug 14 '09 at 19:25
  • See a more up to date answer below (the one by OffBySome): http://stackoverflow.com/questions/666941/how-do-i-add-nunit-as-a-test-framework-option-for-asp-net-mvc-to-visual-web-deve/5696345#5696345 – Julian Oct 28 '11 at 17:12
5

Edit: There's an easier solution below.

I got the Create Unit Test Project dialog working with NUnit and Visual Web Developer Express. I had to add an NUnit test template to the following location: %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\VWDExpress\ProjectTemplates\CSharp\Test\1033 (I had to create the Test\1033 subfolders).

Then I ran VWDExpress /setup per Craig Stuntz's recommendation (from %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE).

And it worked!

Note: I had previously added registry settings from here but applied them to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VWDExpress\9.0\MVC\TestProjectTemplates.

For your convenience, here are the differences from the ASP.NET MVC Test Framework Integration Walkthrough article:

Step 1. Copy the template zip files to %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\VWDExpress\ProjectTemplates\CSharp\Test\1033 (note the VWDExpress folder)

Step 2. Before merging the registry file(s), edit them to point to the appropriate location under: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VWDExpress\9.0\MVC\TestProjectTemplates (note the VWDExpress key)

Step 4. Run VWDExpress /setup instead of devenv /setup

Community
  • 1
  • 1
Mike Henry
  • 2,401
  • 1
  • 25
  • 34
3

Thanks all that's great! I had a few wrinkles, because I only have MVC2 with VWD express 2010. So various things assumed in the earlier articles and pointers don't quite work out.

I made an outline for what helped me, starting with the base of: the templates and .CMD file in the "Updated NUnit Templates for ASP.Net MVC 1.0 RTM" article.

  1. Back-up your registery
  2. Unzip the nunitRTM.zip file from 1.
  3. You can run the command file, it doesn't look for VWDexpress 2010; so look carefully to see how much you need to fix-up or do manually (see following steps)
  4. Copy the template (.ZIP) files to C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\VWDExpress\ProjectTemplates ... Csharp\test and VisualBasic\test
  5. I made two registry update files: Csharp\NUnitExpress2010.reg and VisualBasic\NUnitExpress2010.reg; from the Csharp\NUnitExpress.reg and VisualBasic\NUnitExpress.reg files (respectively).
  6. The main difference is the use registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft**VWDExpress****10.0****MVC2**\TestProjectTemplates
    Registry entry meanings are covered in: "ASP.NET MVC Test Framework Integration"
  7. Update the reistry: regedit.exe /s "Visual Basic\NUnitExpress2010.reg" (e.g.)
  8. Run set-up for Visual Web Designer: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\VWDExpress.exe" /setup
  9. Fire-up VWD express and open a new project -- There were the nUnit templates.

I found it tedious, still persevere it will be worth it.

will
  • 4,799
  • 8
  • 54
  • 90
1

In VWD Express, use

VWDExpress /setup

in lieu of

devenv /setup
Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273
  • Thanks. I tried that, but still no Create Unit Test Project dialog. I wonder which step I could have messed up. – Mike Henry Mar 20 '09 at 20:24
1

For a quick test, try xUnit (more details here). If it works, then digg further on NUnit integration.

alexandrul
  • 12,856
  • 13
  • 72
  • 99
  • Thanks. I tried running the xunit.installer.exe from xUnit.net 1.1 but received the following exception: System.ArgumentNullException: Value cannot be null. Parameter name: path1 at System.IO.Path.Combine(String path1, String path2) at Xunit.Installer.MvcHelper.GetVs90ProjectTemplatePath() ... – Mike Henry Mar 25 '09 at 19:34
  • In my case I had to create the "Test\1033\" folder in "...\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp" – alexandrul Mar 26 '09 at 06:00
  • Your comment got me thinking. I already had my NUnit test template in that folder, but not in "...\Microsoft Visual Studio 9.0\Common7\IDE\VWDExpress\ProjectTemplates\CSharp\Test\1033". – Mike Henry Mar 26 '09 at 15:02
1

I just found a blog article that also addresses this issue: NUnit VWD Express MVC setup « A Coders Life

Mike Henry
  • 2,401
  • 1
  • 25
  • 34
0

Have you installed the full .net 2.0 NUnit: http://www.nunit.org/index.php?p=download

Jonathan Parker
  • 6,705
  • 3
  • 43
  • 54
  • Yes, I installed the full .net 2.0 NUnit 2.4.8 using the MSI installer. I suppose it may be worth trying to uninstall and reinstall NUnit since I installed NUnit before ASP.NET MVC. – Mike Henry Mar 25 '09 at 19:31
  • I tried reinstalling NUnit and rerunning VWDExpress /setup but I still do not see the Create Unit Test Project dialog. – Mike Henry Mar 25 '09 at 19:48
0

I've been struggling with that same thing as well. What I've done at the end was I took the unit tests created by the ASP.NET MVC team (found in the installer), mixed it with the templates provided by the pages you've mentioned and voila! It works just great :D

You can download the whole package here

Best regards, Matthias.

Matthias Hryniszak
  • 3,099
  • 3
  • 36
  • 51