【问题标题】:devops VSTest@2: ##[error]Could not find testhostdevops VSTest@2:##[错误]找不到测试主机
【发布时间】:2022-08-22 09:55:30
【问题描述】:

我们正在使用 devops 构建我们的 .net 4.7.2 应用程序。作为其中的一部分,我们正在运行使用 nunit 框架和测试运行器的单元测试。

它已经运行了大约 18 个月,但在最后一天刚刚停止工作:(

它使用标准模板来运行测试,看起来像:

      - task: VSTest@2
        displayName: \"Running tests\"
        inputs:
          testSelector: \'testAssemblies\'
          testAssemblyVer2: |
              **\\*test*.dll
              !**\\*TestAdapter.dll
              !**\\obj\\**
          searchFolder: \'$(System.DefaultWorkingDirectory)\'

但是,现在它使用以下日志使该步骤失败:

NUnit 适配器 4.2.0.0:测试执行开始 在 D:\\a\\1\\s\\Configuration.Tests\\bin\\Release\\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中运行所有测试 NUnit3TestExecutor 使用当前发现模式发现了 0 个 NUnit 测试用例中的 0 个,显式运行 在 D:\\a\\1\\s\\Configuration.Tests\\bin\\Release\\testcentric.engine.metadata.dll 中运行所有测试 NUnit3TestExecutor 使用当前发现模式发现了 0 个 NUnit 测试用例中的 0 个,显式运行 在 D:\\a\\1\\s\\Api.Tests\\bin\\Release\\testcentric.engine.metadata.dll 中运行所有测试 NUnit3TestExecutor 使用当前发现模式发现了 0 个 NUnit 测试用例中的 0 个,显式运行 在 D:\\a\\1\\s\\CommunicationTests\\bin\\Release\\testcentric.engine.metadata.dll 中运行所有测试 NUnit3TestExecutor 使用当前发现模式发现了 0 个 NUnit 测试用例中的 0 个,显式运行 在 D:\\a\\1\\s\\Domain.Tests\\bin\\Release\\testcentric.engine.metadata.dll 中运行所有测试 NUnit3TestExecutor 使用当前发现模式发现了 0 个 NUnit 测试用例中的 0 个,显式运行 在 D:\\a\\1\\s\\packages\\NUnit3TestAdapter.4.2.1\\build\\net35\\testcentric.engine.metadata.dll 中运行所有测试 NUnit3TestExecutor 使用当前发现模式发现了 0 个 NUnit 测试用例中的 0 个,显式运行 NUnit 适配器 4.2.0.0:测试执行完成 D:\\a\\1\\s\\Configuration.Tests\\bin\\Release\\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll D:\\a\\1\\s\ 中没有可用的测试\Configuration.Tests\\bin\\Release\\testcentric.engine.metadata.dll D:\\a\\1\\s\\Api.Tests\\bin\\Release\\testcentric.engine.metadata.dll D:\\a\\1\\s\\CommunicationTests\\bin\\Release\\testcentric.engine.metadata.dll D:\\a\\1\\s\\Domain.Tests\\bin\\发布\\testcentric.engine.metadata.dll D:\\a\\1\\s\\packages\\NUnit3TestAdapter.4.2.1\\build\\net35\\testcentric.engine.metadata.dll。确保测试发现者和执行者已注册并且平台和框架版本设置正确,然后重试。 ##[错误]找不到测试主机 结果文件:D:\\a_temp\\TestResults\\VssAdministrator_WIN-FVJ4KUK6IFI_2022-08-18_12_38_44.trx ##[错误]测试运行中止。 总测试:未知 通过:110 总时间:16.7203 秒 Vstest.console.exe 以代码 1 退出。 ****************** 已完成测试执行 ********************* 测试结果文件:D:\\a_temp\\TestResults\\VssAdministrator_WIN-FVJ4KUK6IFI_2022-08-18_12_38_44.trx 创建的测试运行:1080 发布测试结果:112 发布测试结果以测试运行“1080”。 TestResults 发布 112,测试运行 id:1080 测试结果发布112,剩余:0。测试运行id:1080 公布的测试结果:112 发布附件:1 执行结果代码 1 非零,检查失败结果 完成测试执行模型... ##[警告]Vstest 因错误而失败。检查失败的日志。可能有失败的测试。 ##[错误]错误:进程\'D:\\a_tasks\\VSTest_ef087383-ee5e-42c7-9a53- ab56c98420f9\\2.205.0\\Modules\\DTAExecutionHost.exe\' 失败,退出代码为 1 ##[error]Vstest 因错误而失败。检查失败的日志。可能有失败的测试。 完成:运行测试

通过这个日志,似乎 nunit 测试已经成功运行,但它可能正在尝试运行 mstests?当 devops 获得更新并破坏工作管道时,这是令人沮丧的。

    标签: azure-devops nunit devops mstest azure-pipelines-yaml


    【解决方案1】:

    我们也有类似的情况。

    单元测试使用 Xunit 运行。 /TestAdapterPath:"D:\a\1\s" 开始测试执行,请稍候... 共有 36 个测试文件与指定的模式匹配。 2.4828

    ##[错误]找不到测试主机

    数据收集器“代码覆盖率”消息:没有可用的代码覆盖率数据。探查器未初始化.. 2.0273

    ##[错误]找不到测试主机

    数据收集器“代码覆盖率”消息:没有可用的代码覆盖率数据。探查器未初始化.. 2.3746

    ##[错误]找不到测试主机

    数据收集器“代码覆盖率”消息:没有可用的代码覆盖率数据。探查器未初始化.. 1.992

    ##[错误]找不到测试主机

    数据收集器“代码覆盖率”消息:没有可用的代码覆盖率数据。探查器未初始化.. 4.8409 ##[错误]找不到测试主机

    数据收集器“代码覆盖率”消息:没有可用的代码覆盖率数据。探查器未初始化.. 2.1874 ##[错误]找不到测试主机

    我比较了成功运行和失败运行的输出,发现测试平台的版本不同。如果您不指定版本,则默认版本将是最新版本,并且可能是预览版本。所以我在 yaml 中添加了一些东西来指定一个可行的版本。

    - task: VisualStudioTestPlatformInstaller@1
      inputs:
        versionSelector: 'SpecificVersion'
        testPlatformVersion: '17.2.0'
    - task: VSTest@2
      inputs:
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
        codeCoverageEnabled: True
        vsTestVersion: 'toolsInstaller'
    

    https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/vstest?view=azure-devops https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/vstest-platform-tool-installer?view=azure-devops

    【讨论】:

      猜你喜欢
      • 2020-08-13
      • 1970-01-01
      • 2020-11-18
      • 2023-01-27
      • 1970-01-01
      • 1970-01-01
      • 2021-05-07
      • 2020-07-28
      • 1970-01-01
      相关资源
      最近更新 更多