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=184.108.40.206, 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=220.127.116.11, 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: