How To Write Unit Tests in Visual Studio Express Using NUnit
Visual Studio Express is a scaled down version of Visual Studio. The product is available for free and can be downloaded from Microsoft. However, it 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
To write unit tests in Visual Studio Express using Nunit follow these steps.
- Download Nunit
- Create a class library project in Visual Studio Express
- Add a reference to nunit.framework.dll (This file was downloaded as part of step 1)
- Write your test code (Add your test classes to the class library you added as part of step 2)
The test code follows the following format:

Figure1 - Sample NUnit test
It is important that you put the Test attribute on every test method and the TextFixture attribute on the class itself.
Start the Nunit GUI application and open the class project which was created as part of step 2).
Now, all you have to do is select the tests to run from the test tree on the left and press the Run button. A green bar will appear if the test(s) ran sucessfully.

Figure2 - NUnit test runner
Feel free to comment on this article!
Your name
Title
Your comment