【问题标题】:Azure Pipeline Error: vstest.console process failed to connect to testhost processAzure 管道错误:vstest.console 进程无法连接到 testhost 进程
【发布时间】:2020-09-08 04:28:08
【问题描述】:

我正在将我的 azure 管道转换为 YAML 管道。当我触发构建时,它在单元测试步骤中失败并给出如下错误

[错误]vstest.console 进程在 90 秒后无法连接到 testhost 进程。这可能是由于机器速度慢,请设置环境变量 VSTEST_CONNECTION_TIMEOUT 增加超时时间。

我找不到在任何地方添加 VSTEST_CONNECTION_TIMEOUT 值的方法。你能帮我解决这个问题吗?

这是我正在使用的示例 .yml

- task: VSTest@2
        displayName: 'Test'
        inputs:
            testAssemblyVer2: '**\bin\**\Tests.dll'
            testFiltercriteria: 'TestCategory=Unit'
            runSettingsFile: XYZ.Tests/codecoverage.runsettings
            codeCoverageEnabled: true
            platform: '$(BuildPlatform)'
            configuration: '$(BuildConfiguration)'
            diagnosticsEnabled: true

【问题讨论】:

  • 嗨,您查看了以下解决方案吗?进展如何?
  • 下面的一个对我不起作用。我的项目使用的是 dot net core 2.2,我正在将管道 dot net core 版本配置为 3.1。更新正确版本后,它开始工作。

标签: .net-core yaml azure-pipelines vs-unit-testing-framework azure-pipelines-yaml


【解决方案1】:

我建议您改用 dotnetCli 任务。它更短、更清晰、更直接(它将与在控制台中执行 dotnet test 具有“相同”的效果)

- task: DotNetCoreCLI@2
  displayName: 'Run tests'
  inputs:
    command: 'test'

即使在 microsoft documentation page 中,他们也使用 DotNetCoreCLI 任务。

【讨论】:

    【解决方案2】:

    如果 vstest 任务可以在您的经典管道上成功运行。它也应该在 yaml 管道中工作。您可以检查代理池选择和任务设置,以确保它们在 yaml 和经典管道中相同。

    1,您的单元测试似乎在 yaml 管道中的 Vs2017 上运行。您可以尝试在windows-latest 代理上运行管道以在 Vs2019 上运行测试。

    如果您的管道必须在特定代理上运行。您可以使用VisualStudioTestPlatformInstaller 任务下载最新版本。然后为 Vstest 任务设置vsTestVersion: toolsInstaller。见下文:

    - task: VisualStudioTestPlatformInstaller@1
    
    - task: VSTest@2
      displayName: 'Test'
      inputs:
        testAssemblyVer2: '**\bin\**\Tests.dll'
        ...
        ...
        vsTestVersion: toolsInstaller
    

    2,您也可以在thread查看解决方案。正如解决方案deleting the entire solution folder, re-cloning the project 中提到的那样。如果您在 自托管代理 上运行管道。您可以尝试在 yaml 管道中使用Checkout 在克隆您的存储库之前清理源文件夹。见下文:

    steps:
    - checkout: self 
      clean: true
    

    您也可以尝试将以下内容添加到元素 <CodeCoverage> 下的 codecoverage.runsettings 文件中,以排除线程中提到的 microsoft 程序集。

    <ModulePath>.*microsoft\.codeanalysis\.csharp\.dll$</ModulePath>
    <ModulePath>.*microsoft\.codeanalysis\.csharp\.workspaces\.dll$</ModulePath>
    <ModulePath>.*microsoft\.codeanalysis\.dll$</ModulePath>
    <ModulePath>.*microsoft\.codeanalysis\.workspaces\.dll$</ModulePath>
    

    3,您也可以尝试将“Microsoft.NET.Test.Sdk”更新到最新版本以进行测试项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-11
      • 2021-11-08
      • 2021-07-29
      • 1970-01-01
      • 2017-05-15
      • 1970-01-01
      相关资源
      最近更新 更多