【问题标题】:Run Google Test with build pipeline in Azure DevOps在 Azure DevOps 中使用构建管道运行 Google 测试
【发布时间】:2020-01-29 16:00:04
【问题描述】:

我无法让我的 gtest 在我的构建管道中运行。我的解决方案非常适合在 Visual Studio 2017 中构建和运行测试用例。在 DevOps 环境中,我使用 .Net 桌面设置并稍作修改。构建任务在管道中也可以正常工作。

我尝试使用默认的 VSTest 任务,但我不确定它是否适合运行使用 VS IDE 中的 Visual Studio 项目创建的 Google 测试。

构建管道 yml 脚本

# .NET Desktop

trigger:
- master

# Install build environment 
pool:
  vmImage: 'windows-latest'
  name: Hosted VS2017

variables:
  solution: '**/*.sln'
  buildPlatform: 'x86'
  buildConfiguration: 'Debug'

steps:

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

# Build VS solutions including gtest project.   
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

# Run gTest, this task not working see log below.  
- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

VSTest 日志输出

Running tests using vstest.console.exe runner.
======================================================
Test selector : Test assemblies
Test filter criteria : null
Search folder : d:\a\1\s
VisualStudio version selected for test execution : latest
Attempting to find vstest.console from a visual studio installation with version [16.0,17.0).
Attempting to find vstest.console from a visual studio build tools installation with version [16.0,17.0).
Attempting to find vstest.console from a visual studio installation with version [15.0,16.0).
Run in parallel : false
Run in isolation : false
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Diagnostics enabled : false
SystemVssConnection exists true
Run the tests locally using vstest.console.exe
========================================================
##[warning]No test assemblies found matching the pattern: **\*test*.dll,!**\*TestAdapter.dll,!**\obj\**.

【问题讨论】:

    标签: azure-devops visual-studio-2017 yaml azure-pipelines googletest


    【解决方案1】:

    是的,VSTest 任务将使用VSTest.Console.exe。它能够运行自定义测试适配器(如 Google 测试适配器)。

    但是,通过 Hosted VS2017 build agent 的内置 Included Software 后,它并没有列出。如果是这样,您可以使用Self-hosted Windows agents

    您可以将 Google 测试适配器下载为 Visual Studio 扩展,将其解压缩(将 .vsix 文件重命名为 .zip)并将整个解压缩后的文件夹放在您的构建代理计算机上的某个位置。然后构建步骤必须指向该目录。

    当然,此外,您的项目还应包含“googletest”NuGet 包以运行测试。

    如果您仍然无法使其工作,请远程构建代理机器并通过 Azure DevOps 管道手动运行构建和测试使用 Visual Studio 或命令行。如果是环境问题,这将缩小范围。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-14
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 2020-01-08
      • 1970-01-01
      • 2021-01-21
      • 1970-01-01
      相关资源
      最近更新 更多