c# - VSTEST@2 - 错误找不到测试主机 | Azure管道

标签 c# .net azure azure-pipelines vstest

我在 vstest@2 任务的帮助下在 azure 管道上运行测试解决方案。 Pipeline 将测试用例分发到 4 个代理上,然后运行它们。

任务yaml:

  - task: VSTest@2
    inputs:
      testSelector: 'testAssemblies'
      testAssemblyVer2: |
        **/*.Tests.dll
      searchFolder: '$(System.DefaultWorkingDirectory)'
      distributionBatchType: basedOnExecutionTime
      runInParallel: true

在运行开始时,我收到一堆这些消息:

##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)

之后测试开始通过并进一步运行。

对此我有两个问题 - 这些消息实际上意味着什么/我应该以某种方式进行干预吗?

我可以以某种方式禁用这些消息,这样它们就不会向我的运行日志发送垃圾邮件吗?

最佳答案

您可以尝试以下解决方法来解决上述问题,而不是使用 **/*.Tests.dll 尝试使用 **\*test.dll

- task: VSTest@2
    inputs:
      testSelector: 'testAssemblies'
      testAssemblyVer2: |
        **\*test.dll
      searchFolder: '$(System.DefaultWorkingDirectory)'
      distributionBatchType: basedOnExecutionTime
      runInParallel: true

并且还基于MS DOC :

The VsTest task doesn't support running tests that target multiple target frameworks at a time as this is a limitation from the vstest platform side. If you want to run tests that belong to multiple target frameworks, you'll need multiple instances of the vstest task, one per set of dlls that target a particular framework.

有关更多信息,请参阅以下类似问题的链接:

关于c# - VSTEST@2 - 错误找不到测试主机 | Azure管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71955269/

相关文章:

c# - 我如何使用 ASP .NET Framework 4.6 使用 graphql api

c# - 将列表拆分为水平分组的子列表列表

c# - 跨程序集移动的反序列化类型

.net - 尽管有 timeBeginPeriod(1),为什么最小 Threading.Timer 间隔为 15ms

.net - Microsoft Graph 身份验证重新处理其他声明

c# - 无法将 iOS Autolayout 乘数设置为零

c# - 无法保存对数据库的更改

.net - 在 .NET 中,对象引用的具体类型是什么?

PowerShell - 使用 Microsoft 帐户连接到 Azure Active Directory

用于从特定分支创建分支的 Azure DevOps Rest API