【问题标题】:Exception discovering xUnit.net tests with Visual Studio Online build server使用 Visual Studio Online 构建服务器发现 xUnit.net 测试的异常
【发布时间】:2014-04-05 10:40:45
【问题描述】:

我将 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

我怎样才能让它工作?有谁知道解决方法?我可以以某种方式隐藏错误消息吗?

【问题讨论】:

    标签: unit-testing tfsbuild xunit.net azure-devops


    【解决方案1】:

    testrunner 尝试在xunit.runner.visualstudio.testadapter.dll 中发现单元测试。为什么?因为它符合*.test*.dll 的默认测试源规范。

    将默认测试源规范更改为 *.tests.dll 或更具体的内容时,它将起作用。

    来源:http://erictummers.wordpress.com/2014/02/11/execute-xunit-tests-on-hosted-build-controller/

    【讨论】:

    • 我在我的 Visual Studio Online 版本中使用 NUnit 测试适配器遇到了类似的情况,并按照您上面的建议重命名通配符也修复了它。我收到的错误消息:Dependent Assembly Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a of C:\a\bin\NUnit.VisualStudio.TestAdapter.dll not found. Can be ignored if not a NUnit project.希望这可以帮助除 NUnit 之外偶然发现此问题的其他人。
    猜你喜欢
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-13
    • 1970-01-01
    • 2015-01-08
    • 1970-01-01
    相关资源
    最近更新 更多