使用Visual Studio Online构建服务器时发现xUnit.net测试的异常

9

我正在使用Xunit.net和Visual Studio Online托管构建。我的测试在本地和构建服务器上都能正常发现和运行。但是在构建服务器上,我遇到了这个异常(导致构建达到“部分成功”的状态)。这很奇怪,因为实际上我的所有测试都已经被发现并运行了。

[xUnit.net 00:00:01.3170293] Exception discovering tests from C:\a\bin\xunit.runner.visualstudio.testadapter.dll: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value HKLM\Software\Microsoft\Fusion!EnableLog to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at Xunit.Sdk.Executor.EnumerateTests..ctor(Executor executor, Object _handler)$$RethrowMarker$$   at ExceptionExtensions.RethrowWithNoStackTraceLoss(Exception ex)
   at Xunit.RemoteAppDomainManager.CreateObjectTObject
   at Xunit.Xunit1Executor.EnumerateTests(ICallbackEventHandler handler)
   at Xunit.Xunit1.Find(Predicate`1 filter, Boolean includeSourceInformation, IMessageSink messageSink)
   at Xunit.Xunit1.Find(Boolean includeSourceInformation, IMessageSink messageSink)
   at Xunit.XunitFrontController.Find(Boolean includeSourceInformation, IMessageSink messageSink)
   at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.GetTests(IEnumerable`1 sources, IMessageLogger logger, XunitVisualStudioSettings settings, Stopwatch stopwatch)

See http://go.microsoft.com/fwlink/?LinkId=254169

我在测试项目中安装了以下NuGet包:
  • xunit 1.9.2
  • xunit.runner.visualstudio 0.99.2
其他单元测试框架,如MS Test和NUnit,均可以正常工作。这使我认为问题出在Xunit.net上,而不是Visual Studio Online上。
我还在xUnit.net GitHub上开了一个问题,但它仍未解决。 https://github.com/xunit/xunit/issues/47 如何让它工作?有人知道解决方法吗?我能否以某种方式抑制错误消息?
1个回答

15

4
我之前在使用 NUnit Test Adapter 进行 Visual Studio Online 构建时遇到了类似的情况,按照您上面建议的将通配符重命名后问题也得到了解决。我之前遇到的错误信息是:C:\a\bin\NUnit.VisualStudio.TestAdapter.dllDependent Assembly Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 未找到。如果不是 NUnit 项目,则可以忽略此错误消息。希望这个信息能对其他遇到同样问题的人有所帮助。 - Jon Comtois

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接