尽管所有测试都通过,但TeamCity NUnit构建步骤失败

时间:2013-05-29 13:46:16

标签: build continuous-integration nunit teamcity

我正在设置TeamCity来运行一些NUnit测试,TeamCity报告所有测试通过,但它报告构建失败,并显示错误消息“新构建状态为:: NUnit错误,{build.status.text }”。 深入到构建日志中我可以看到加载测试中的程序失败,这是报告的错误;

[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)

那么,为什么文件不能加载我想知道?测试全部通过了,为什么现在甚至需要加载这个文件呢?

我已尝试在NUnit构建步骤中将.NET运行时设置为x86,但无济于事。

环境:Windows 7,VS 2012 Update 2,编译为.NET 4.0,NUnit 2.6.2,TeamCity 7.1。

1 个答案:

答案 0 :(得分:6)

如果仍然有效;
这是一个非常明显的错误:

  

System.IO.FileNotFoundException:无法加载文件或程序集“MyProject.Browser,Version = 0.24.0.0,Culture = neutral,PublicKeyToken = null”或其依赖项之一。系统找不到指定的文件。

  1. 您必须创建构建步骤以编译测试

  2. 创建另一个构建步骤NUnit并将路径传递给程序集文件,您可以使用通配符,此处有更多信息https://stackoverflow.com/a/16629676/1075077