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

Which blog engine?

So the time has come to move to a more advanced blog engine for my blog. blogger.com , Google's blogging service, has served me well. It's incredibly easy to use and to get started with, along with having some great features such as inbuilt stats; however now I need a few more advanced features and greater control over the blog. There's a vast array of blog engines out there, some free, some paid for, some hosted, some self-hosted, and picking which one is best or the right choice could be a little bit tricky. This article from Mashable lists most of the main options and bigger players -  http://mashable.com/2007/08/06/free-blog-hosts/ . There are a few parameters that I've kind of decided on Ease of installation/compatibility and support with web hosts Simple to use. I don't want to spend ages clicking around just to add a post or format it. Feature rich and well supported. Most blog engines should have a fairly standard set of features now such RSS/ATOM fe

Enable .NET 8 Preview in Visual Studio

Download the SDK using Download .NET 8.0 (Linux, macOS, and Windows) (microsoft.com)  and install it. To enable projects to target the .NET 8 preview framework, the preview option in Visual Studio needs to be enabled, otherwise the option to target .NET 8 will not be available as shown below when setting up a new project (or trying to upgrade an existing one). To allow .NET 8 Preview to be used as a target framework for projects, the preview option needs to be enabled in Visual Studio. Open Visual Studio and select "Continue without code" In Visual Studio, select Tools then Options In Options, under Environment, select Preview Features and enable Use previews of the .NET SDK.

SQL Server - Remove Non-Alphanumeric Characters from String

The following SQL function will remove and strip all non-alphanumeric characters from a string. CREATE FUNCTION [dbo].[fncRemoveNonAlphanumericChars](@Temp VarChar(1000)) RETURNS VarChar(1000) AS BEGIN WHILE PatIndex('%[^A-Za-z0-9]%', @Temp) > 0 SET @Temp = Stuff(@Temp, PatIndex('%[^A-Za-z0-9]%', @Temp), 1, '') RETURN @TEmp END Example: SELECT dbo.fncRemoveNonAlphanumericChars('abc...DEF,,,GHI(((123)))456jklmn') Result: abcDEFGHI123456jklmn