In a previous blog entry, I talked about how you can add unit testing capability to projects in Visual Studio Express by using Nunit.
Instead of using the Nunit Gui client, you can automate the test run by using a post build event and the console version of the Nunit client.
To automatically run your tests when building: Add the following line to your Visual Studio post build event:
“[Local Nunit path]\nunit-console.exe” $(TargetDir)MyTests.dll /xml $(TargetDir)results.xml
This will start Nunit (behind the scenes), and run all tests defined in MyTests.dll. The test results are written to results.xml.
It is worth noting that the build will fail if any of the unit tests fail.
Tags: Automated, Torgeir Helgevold, Unit testing in Visual Studio Express