Cook Computing

VS2005 and NUnit

October 29, 2005 Written by Charles Cook

I downloaded VS2005 yesterday but didn't get around to installing it today (I used the auto-uninstall tool mentioned here). I then tried building and testing XML-RPC.NET. The build went fine but I had a few problems with NUnit.

Starting with NUnit version 2.2.0 already installed on my home machine, the first problem was that by default NUnit does not support version 2.0 of .NET. You need to add a line to the nunit-console.exe.config and nunit-gui.exe.config files to add support for version 2.0.50727 of .NET:

    <supportedRuntime version="v2.0.50727" />
    <supportedRuntime version="v1.1.4322" />
    <supportedRuntime version="v1.0.3705" />
    <requiredRuntime version="v1.0.3705" />

The new line has to be the first child of the <startup> element and I seem to remember that I had to uncomment <startup> in at least one of the config files.

Then when I tried to run a test I got a "Cross-thread operation not valid" error message. To fix this I installed the latest "iteration" build of NUnit - 2.2.2 - after seeing a message from Charlie Poole recommending this for .NET 2.0.

Finally none of my tests were picked up by the test runner. I was relying on test methods being recognized by start with the word "test", e.g. "testInt_NullType" which no longer works out of the box. It now appears to be mandatory to decorate test methods with NUnit.Framework.TestAttribute.