根据您提供的更详细的日志,构建失败的真正原因似乎是:
...
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)
...
而且我相信它的发生正是因为我在评论中链接的SO 线程中提到的原因,即您正在从obj文件夹运行测试,而它应该是bin。但这仍然只是一个猜测,因为您没有提供 NUnit 步骤配置。
要解决此问题,您应该明确包含单元测试的程序集所在的路径。像这样的东西:
**\bin\**\*.Tests.dll
在“列出程序集文件:”下。这样来自obj文件夹的程序集将不会得到测试,请参阅此 SO 线程。