1
votes

I have problems to get my gtest runing in my build pipeline. My solution works well to build and run test case in Visual Studio 2017. On the DevOps environment I use .Net Desktop setup with minor modification. The build task work fine as well in pipeline.

I try use default VSTest task, but I'm not sure it right task for run Google Test that is create with Visual Studio project from VS IDE.

Build pipline yml script

# .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 log output

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\**.
1

1 Answers

1
votes

Yes, VSTest task which will use VSTest.Console.exe. It's able to run custom test adapters (like the Google Test Adapter).

However, after go through the build-in Included Software of Hosted VS2017 build agent, it's not listed. If so, you could use Self-hosted Windows agents.

You can download the Google Test Adapter as Visual Studio Extension, unzip it (rename .vsix file to .zip) and place that entire unzipped folder somewhere on your Build agent machine. The build step then has to point to that directory.

enter image description here

Additionally of course, your project should include the "googletest" NuGet package in order to run the tests.

If you still not able to get it work, please remote to build agent machine and manually run the build and test use visual studio or command line instead through Azure DevOps pipeline. This will narrow down if it's an environment issue.