Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity NUnit build step failing although all tests pass

I'm setting up TeamCity to run some NUnit tests, TeamCity reports that all the test pass but it reports the build as a fail with the error message 'New build status is : : NUnit error, {build.status.text}'. Digging in to the build log I can see that there's a failure to load the program under test, here's the reported error;

[Step 2/2] NUnit error running tests in 'C:\TeamCity\buildAgent\work\f73bb9cce36ccd59\ProjectName.Web\ProjectName.BrowserTests\obj\Release\MyProject.BrowserTests.dll' assembly
Loading assembly is compiled for v4.0.30319, MSIL
NUnit runner runtime is v4.0.30319, x86
System.IO.FileNotFoundException: Could not load file or assembly 'MyProject.Browser, Version=0.24.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'MyProject.Browser, Version=0.24.0.0, Culture=neutral, PublicKeyToken=null'

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)

So, why can the file not be loaded I wonder? The tests have all passed so why does this file even need to be loaded now?

I've experimented with setting the .NET runtime to x86 in the NUnit build step, to no avail.

Environment: Windows 7, VS 2012 Update 2, compiling to .NET 4.0, NUnit 2.6.2, TeamCity 7.1.

like image 553
Stuart Hallows Avatar asked May 29 '13 13:05

Stuart Hallows


1 Answers

If this is still active;
It is a pretty clear error:

System.IO.FileNotFoundException: Could not load file or assembly 'MyProject.Browser, Version=0.24.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

  1. You have to create build step to compile tests

  2. Create another build step NUnit and pass path to assembly file you can use wildcards, more info https://stackoverflow.com/a/16629676/1075077 here.

like image 88
Dejan Dakić Avatar answered Oct 26 '22 09:10

Dejan Dakić