Visual-studio – Unit testing in Visual Studio 2008 Standard

unit testingvisual-studio-2008

I am using Visual Studio 2008 standard editing for my personal projects. This edition does not support unit testing out of the box. I have some experience with the test possibilities in Visual Studio Team System.

What (free) options do I have if I want to do unit testing? Is it possible to open the test projects made with Microsoft test by others?

Best Answer

I am using NUnit with Visual Studio 2008. In the past I have also used it with Visual Studio 2005.

It works great.

For running it I use a project where the unit tests are defined, separate from the main project. For interactive use I then set this project to the default project (right-click on project/Set as Startup Project) and set Properties/Debug/"Start external program" in this project to something like

C:\Program Files\NUnit\bin\nunit-x86.exe

In the same screen "Start Options/Command line arguments" is set to something like

..\..\..\temp2\MSQlib1,2008-03-14a.nunit"\MSQlib1,2008-03-14a.nunit

This points to the NUnit project file ("MSQlib1,2008-03-14a.nunit" in this example)- the ".."s are due to being relative to the bin\Debug folder where the DLL for the project is located (the application is this case is the NUnit GUI application) and which will be the current directory when debugging is started.

The result is that the NUnit GUI application is started when F5 is pressed in Visual Studio and calls back into the application when the unit tests are run from the NUnit GUI application.

This allows breakpoints to be set in the unit tests (if needed). E.g. to get information on why a unit test failed by doing inspection with the debugger. In my case this has sometimes been necessary when the mass of elements carbon, hydrogen, nitrogen, oxygen and sulphur were changed slightly and masses of amino acids no longer were within limits.