After many days of trial and error I would like to reach out to the community for help.
I have a CMake / C++ project here, built using Azure Devops Pipeline. It is using SonarCloud for analysis and some of it works (static analysis, code smells, issues, etc) but the Test coverage is not. Every analysis always shows a test coverage of 0%.
The project is targeting Windows and built using VisualStudio 2022 with some own prebuilt dependencies. It uses the Boost.Test unit test framework.
I have tried many different things but here is the essence of it.
In my sonar-project.properties I have only a few test coverage linesâŚ
sonar.cfamily.build-wrapper-output=build_wrapper_output_directory
sonar.cfamily.reportingCppStandardOverride=c++17
sonar.tests=unit_test
In azure-pipelines.yml I have this:
- task: SonarCloudPrepare@1
inputs:
SonarCloud: "SonarCloud"
organization: "myorg"
scannerMode: "CLI"
configMode: "file"
extraProperties: |
sonar.cfamily.vscoveragexml.reportsPath=$(Agent.TempDirectory)/TestResults/*/*.xml
... build the project in debug config using build-wrapper-win-x86-64.exe ...
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: Test*.exe
searchFolder: '_build/bin/Debug/unittests'
resultsFolder: '$(Agent.TempDirectory)/TestResults'
pathtoCustomTestAdapters: 'C:\Program Files\Microsoft Visual Studio\2022'
otherConsoleOptions: '/collect:"Code Coverage;Format=Xml"'
codeCoverageEnabled: true
testRunTitle: 'Run tests'
- task: SonarCloudAnalyze@1
When I run this, I see the VSTest target doing its job. It correctly identifies the unit tests and everything, it writes report files and publishes them to Azure Devops, where the conducted unit tests are displayed okay.
When I output the contents of the TestResults directory I see *.trx files as well as .xml coverage files.
Only SonarCloud doesnât seem to get it. I have tried *.coverage files by omitting the Format=Xml option in VSTest but that didnât work either.
In the SonarCloud output I also do not see any Warnings or Errors. Nothing that would explain this.
Does anyone have a hint for me?
Cheers,
Moose