After all yesterday’s work, I came back in this morning to find that yes – hoorah, the project had built successfully on the build server.
But oh no! It no longer built on my machine! Not surprising I guess as I spent so much time trying so many things.
The error I got was:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'nunit-console-runner, Version=184.108.40.20692, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The system cannot find the file specified.
File name: 'nunit-console-runner, Version=220.127.116.1192, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' at NUnit.ConsoleRunner.Class1.Main(String args)
Retracing my steps I found that I had modified the nunit-console.exe.config (found in the nunit \bin\net-2.0 directory).
I had added a supportedRuntime tag:
I removed this and everything is hunky dory again.
If you are getting this error then take a look at that setting. I hope that helps.
Having got maven to build my C# project including unit tests on my developer machine, I was disheartened to be thwarted by a new lot of errors on the build server.
I took over this project from another developer and so was not certain what the state server configuration was in.
nunit executable in the PATH
The first hurdle was realising that the nunit executable must have it’s location included in the server’s PATH environment variable.
HOORAH, I thought. Now I can move on.
The unit tests still wouldn’t build. The next error was
ProcessModel: Default DomainUsage: Single
Execution Runtime: Default
System.BadImageFormatException: Could not load file or assembly 'BBCNewsI.MPS.Tests, Version=18.104.22.168, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'BBCNewsI.MPS.Tests, Version=22.214.171.124, Culture=neutral, PublicKeyToken=null'
Why couldn’t maven see my test project?? I can see it! After looking in a lot of wrong places I found the answer. Nunit was running the tests as 64 bit because the build server is 64 bit. As the code is dot net 2.0 and built as 32 bit, this is not good.
Maven pom.xml file
Again I looked in the wrong place. The fix for this is not in nunit but in your maven pom file. You need to force the tests to be run as 32 bit by adding this parameter:
So here is how to describe your test. In your pom file, add the parameter to the maven-test-plugin: