I have a solution with a bunch of projects, some of which also have test projects. These are all compiled for the Any CPU
platform.
In TeamCity, I have a build configuration for NUnit 2.6.4, on which I specify Platform: auto (MSIL)
and Version: 4.0
.
When I run the build, the tests fail with the following message:
NUnit error running tests in 'C:\BuildAgent\work\a58fc6cd9bf63032\JsonApi.Tests\obj\Release\JsonApi.Tests.dll' assembly
Loading assembly is compiled for v4.0.30319, MSIL
NUnit runner runtime is v4.0.30319, x64
Even stranger, when I just now switched off "Run recently failed tests first" (and changed nothing else), I instead got the following:
NUnit error running tests in 'C:\BuildAgent\work\a58fc6cd9bf63032\JsonApi.Owin.Tests\obj\Release\JsonApi.Owin.Tests.dll' assembly
Loading assembly is compiled for v4.0.30319, MSIL
NUnit runner runtime is v4.0.30319, x86
Note that in one case, the runner is x86, while in the other it's x64. In neither case, do they successfully load an assembly compiled for MSIL.
I assume something is off with my build settings here, but what?
Based on the more detailed log you provided, the real cause of build failure appears to be:
...
System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 or one of its dependencies.
The system cannot find the file specified.
File name: 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35|'
Server stack trace:
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object|[|] args, Object server, Object|[|]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
...
And I believe it is happening exactly because of the reason mentioned in the SO thread I have linked in the comments, i.e. you are running tests from obj folder while it should be bin. But this is still only a guess, because you are not providing your NUnit step configuration.
To address the issue you should be explicit about the paths where the assemblies with the unit tests are located. Something like this:
**\bin\**\*.Tests.dll
under "List assembly files:". That way assemblies from obj folders will not get tested, see this SO thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With