Unit testing in Visual Studio Express

By torgeirhelgevold

Visual Studio Express is a scaled down version of Visual Studio. The product is available for free, and can be downloaded from Microsoft. However, the product has one serious short coming; it doesn’t support unit testing!

It is unfortunate that Microsoft has excluded unit testing from Visual Studio Express, but there is still hope for those of you who want to do Test Driven Development. The solution is to add a third party unit testing framework. I have looked into Nunit, which can be downloaded for free from http://www.nunit.org/index.php

To write unit tests in Visual Studio Express using Nunit, follow the following steps.

  1. Download Nunit from http://www.nunit.org/index.php

  2. Create a class library project in Visual Studio Express

  3. Add a reference to nunit.framework.dll (This file was downloaded as part of step 1)

  4. Write your test code.

The test code follows the following format:

using NUnit.Framework;

namespace UnitTests

{

[TestFixture()]

public class UnitTest

{

       [Test]

public void TestAdd()

{

     int a = 4 + 4;

     Assert.AreEqual(8, a);

}

}

Start the Nunit GUI application, and open the class project which was created as part of step 2).

Your tests can be run from the Nunit GUI application, as shown in the following screenshot.

 An alternative to NUnit can be found here:

http://torgeirhelgevold.wordpress.com/2008/05/31/unit-testing-in-visual-studio-express-2008/

One Response to “Unit testing in Visual Studio Express”

  1. torgeirhelgevold Says:

    As an alternative to NUnit, feel free to check out my own tool: ExpressUnit
    http://torgeirhelgevold.wordpress.com/2008/05/31/unit-testing-in-visual-studio-express-2008/

Leave a Reply