I have been trying to run tests using the vstest@2 task within azure devops pipelines and there are never any tests found when using the google test executable. I do have the test assembly specified to google test and Nuget restores google test in an earlier pipeline task.
Here is a snippet of my 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 is the google test executable that is generated using the vsbuild@1 task just before.
Below is the output from the vstest task.
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
I know I can use the command line task and run the google test executable and publish pipeline results from there, but I want to be able to use code coverage with the vstest task.
Edit for comments: When I run the following task just before the VSTest task I get output of all my tests.
- task: CmdLine@2
inputs:
script: '"<project repo output directory>/UnitTesting.exe" --gtest_list_tests'