Skip to main content

Unit testing with VWD 2008 Express & NUnit

Needing to use unit testing with MS Visual Web Developer 2008 Express Edition, I was a little stumped at first as VWD Express doesn't have the Create Unit Test Project dialog box when creating new projects.

Selecting NUnit to use for unit testing wasn't too tough a choice (Visual Studio ships with Visual Studio Team Test but not with VWD 2008 Express). It's free, proven with a track record, and is widely used.

First off NUnit needed to be downloaded and installed. Without stating the obvious NUnit can be downloaded from the website.

After installing NUnit, I grabbed the NUnit Test Templates from Updated NUnit Templates for ASP.Net MVC 1.0 RTM, on the Visual Web Developer Team Blog, and followed the pretty straight forward instructions - unzipped the file and ran installNUnit.cmd.

Everything ran as sweet as after that, with the Create Unit Test Project dialog box popping up after starting up VWD 2008 Express and allowing unit testing of projects.

The comments on the blog entry linked to above seem to throw up a couple of issues and I'm not sure how well this would perform on Windows 7 as I installed on Vista, but I had no problems getting it up and running.

Bug free code... here we come!!!

MS Visual Web Developer 2008 Express Edition can be downloaded from here.

Comments

  1. Hi Jay, Thanks for the good links. I did all this but this didn't happen:

    “Everything ran as sweet as after that, with the Create Unit Test Project dialog box popping up after starting up VWD 2008 Express and allowing unit testing of projects.” I get no dialog pop-up.

    My dilemma is I don't know how to connect a VWD project to an Nuint project.

    In C#, you create a library and add methods, then you can automatically generate a C# unit test. I’m trying everything I can find to do the same with VWD 2008 and Nunit.

    Any comments would be appreciated.

    Thanks.

    ReplyDelete
  2. Hi Anonymous,

    The pop up box and integration into VWD Express 2008 is a result of changes to the registry.

    Make sure you run installNUnit.cmd as admin if you're on Vista or higher machines.

    If you haven't installed VWD Express 2008 in the default location you'll need to edit installNUnit.cmd and update the file paths to locations that match your installed version of VWD Express 2008.

    In VWD Express 2008, you can still add a new class library project if you've started off with a web project and a solution file will be created for you. When the projects are built you can use the resulting dlls independently in nUnit.

    Hope this helps you, gives you a few pointers, and you can get it working.

    I've upgraded to VWD Express 2010 and uninstalled 2008 so I'm a bit rusty on this now.

    NB. I'm sure you know messing with the registry can be pretty dangerous so I can't take any liability if things go a little wrong! :-)

    ReplyDelete
  3. What about the installation in VWD 2010 express? All the paths in the .cmd file are VWD 9.0 relative so none is executed...

    ReplyDelete
  4. Hi Anonymous,

    I've wasn't able to get this working in VWD2010 Express. You can still run tests on your code using NUnit as a standalone application. You just don't get all the nice plu-in integrated features with the IDE.

    Sorry not to be of more help on this one.

    Jay

    ReplyDelete

Post a Comment

Popular posts from this blog

EF CodeFirst Database.SetInitializser Requires Connection to 'master' Database Error

One of the features of EF CodeFirst is the ability to automatically drop and recreate a database if the model changes or if the database does not exist, which is pretty useful when just doing development work. In a web app this is done in the Global.asax file within "protected void Application_Start()" as per this post from Scott Guthrie -  http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx . An example would be: protected void Application_Start() { Database.SetInitializer<yourdbcontex>(new DropCreateDatabaseIfModelChanges<yourdbcontext>()); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); } However when using the Database.SetInitializer and trying to rebuild the database, the following exception may be encountered, especially if using SQL Server Express: "This operation requires a connection to the 'master'...

VWD Express 2010 Unit Tests with xUnit and MVC Templates

Microsoft's Visual Web Developer 2010 Express (VWD 2010 Express), by default does not come with a built in unit testing solution. However the ability is there to use unit tests with the Express version as can be seen when creating a new MVC project. Tech spec stuff: Microsoft Windows 7 Microsoft Visual Studio 2010 Express, Version 10.0.40219.1 SP1 Microsfot .NET Framework Version 4.0.30319 SP1 Getting started with xUnit xUnit is a "developer testing framework, built to support Test Driven Development (TDD)". There are other unit testing frameworks available (MSTest, nUnit, etc.). There are pro's to each and some better than others but xUnit is pretty straightforward to get up and running with the VWD 2010 Express version. Download and Install xUnit The xUnit project can be found at:  http://xunit.codeplex.com/ . Downloads are available from  http://xunit.codeplex.com/releases/view/62840 . Download the recommended version (currently 1.8 at time of writi...

BlogEngine.NET Security Error After Publishing to IIS7 Web Server

After publishing the initial default set-up of BlogEngine.NET ( http://www.dotnetblogengine.net/ ) to an IIS 7 web server (i.e. not running under debug mode from Visual Studio), the following security exception may appear, stating : System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. BlogEngine.NET Security Exception To get BlogEngine.NET running, the "User Profile" of the application pool that the application runs under in IIS needs to be updated. IIS 7 Application Pools The "Load User Profile", accessed through advanced settings of the application pool, needs to be set to true.  Application Pool Advanced Settings - Load User Profile That should be it to get a proper response from BlogEngine.NET on the server. Of course don't forget to add write permissions for the app_data folder. Thanks to  David Burke ...