在 azure devops 中使用 google test 可执行文件时,vstest 任务找不到任何测试

问题描述 投票:0回答:1

我一直在尝试使用 azure devops 管道中的 vstest@2 任务运行测试,但在使用 google 测试可执行文件时从未发现任何测试。我确实将测试程序集指定为 google test,并且 Nuget 在早期的管道任务中恢复了 google test。

这是我的 yaml 的片段

- task : VSBuild@1
  displayName: 'VSbuild'
  inputs :
    solution : '$(solution)'
    platform : '$(buildPlatform)'
    configuration : ${{parameters.buildconfiguration}}


- task: VSTest@2
  inputs:
    searchFolder:  '$(System.DefaultWorkingDirectory)/<ProjectRepo>'
    resultsFolder: '$(System.DefaultWorkingDirectory)/TestResults'
    testAssemblyVer2: |
      **\UnitTesting.exe
    codeCoverageEnabled: true
    pathtoCustomTestAdapters: '$(System.DefaultWorkingDirectory)/GoogleTestAdapter'
    platform: '$(buildPlatform)'
    configuration: ${{parameters.buildconfiguration}}

UnitTesting.exe 是之前使用 vsbuild@1 任务生成的 google 测试可执行文件。

下面是 vstest 任务的输出。

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe "@D:\a\_temp\c4zmbclzr0a.tmp"
Microsoft (R) Test Execution Command Line Tool Version 16.11.0
Copyright (c) Microsoft Corporation.  All rights reserved.
vstest.console.exe "D:\a\1\s\<project repo>\UnitTesting.exe"
/Settings:"D:\a\_temp\2kvnbwgfz0c.tmp.runsettings"
/EnableCodeCoverage
/Logger:"trx"
/TestAdapterPath:"D:\a\1\s\<project repo>\GoogleTestAdapter"
Starting test execution, please wait...
2.391
A total of 1 test files matched the specified pattern.
No settings file provided through env variable GTA_FALLBACK_SETTINGS
Warning: Using default settings.
Google Test Adapter: Test execution starting...
Found 0 tests in executable D:\a\1\s\<project repo>\UnitTesting.exe
##[error]Test discovery was cancelled after 30s for executable 'D:\a\1\s\<project repo>\UnitTesting.exe'
Google Test execution completed, overall duration: 00:00:31.6375081.
##[error]================
##[error]The following warnings and errors occured during test execution (enable debug mode for more information):
##[error]Test discovery was cancelled after 30s for executable 'D:\a\1\s\<project repo>\UnitTesting.exe'
No test is available in D:\a\1\s\<project repo>\UnitTesting.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Results File: D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx
Attachments:
  D:\a\1\s\TestResults\e27d838c-1572-409c-886c-741d2b1a6e51\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19.22_24_28.coverage
##[error]Test Run Failed.
Vstest.console.exe exited with code 1.
**************** Completed test execution *********************
Test results files: D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx
No Result Found to Publish 'D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx'.
Created test run: 1381422
Publishing test results: 0
Publishing test results to test run '1381422'.
TestResults To Publish 0, Test run id:1381422
Published test results: 0
Publishing Attachments: 2
Execution Result Code 1 is non zero, checking for failed results
Completed TestExecution Model...
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.210.0\Modules\DTAExecutionHost.exe' failed with exit code 1
##[error]Vstest failed with error. Check logs for failures. There might be failed tests.
Finishing: VSTest

我知道我可以使用命令行任务并运行 google test 可执行文件并从那里发布管道结果,但我希望能够在 vstest 任务中使用代码覆盖率。

编辑评论: 当我在 VSTest 任务之前运行以下任务时,我会得到所有测试的输出。

- task: CmdLine@2
  inputs:
    script: '"<project repo output directory>/UnitTesting.exe" --gtest_list_tests'

最终编辑: 我已经确定这个特定问题可能只是谷歌测试适配器的限制。在谷歌测试适配器文档中,它提到当使用 VsTest.Console 运行时,是否可以具有调试功能是未定义的(参见此处)。由于 vstest@2 任务只是 VsTest.Console 的前端,因此它不允许调试和代码覆盖率收集。请参阅(vstest@2 文档)[https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/vstest-v2?view=azure-pipelines#inputs],其中提到您可以将其定向到不同的 vstest.console.exe 以运行不同的版本,以查看它是否只是使用 vstest.console。感谢您为实现此目的提供的所有帮助。

azure-devops azure-pipelines code-coverage googletest vstest
1个回答
0
投票

我已经确定这个具体问题可能只是谷歌测试适配器的限制。在谷歌测试适配器文档中,它提到当使用 VsTest.Console 运行时,是否可以具有调试功能是未定义的(请参见此处)。由于 vstest@2 任务只是 VsTest.Console 的前端,因此它不允许调试和代码覆盖率收集。请参阅(vstest@2 文档)[https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/vstest-v2?view=azure-pipelines#inputs],其中提到您可以将其定向到不同的 vstest.console.exe 以运行不同的版本,以查看它是否只是使用 vstest.console。感谢您为实现此目的提供的所有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.