- ALM used (GitHub)
- CI system used (Github Actions)
- C++17, CMake
Please help me how to let sonar-scanner pick up cobertura reports from gcovr.
To “pick up” GCovr reports and make sure they’re imported into SonarQube, you will need to pass the path to the directory containing the native .gcov reports to
This is noted in our documentation on Test Coverage and Execution
Analysis parameter Description
Path to the directory containing native
*.gcovreports (not the XML reports generated by gcovr)
Based on the gcovr documentation there is even a
sonarqube output format that can be imported as generic coverage data if that is somehow easeir for you.
SonarQube does not accept the cobertura format of gcovr reports for reporting test coverage.
Hi, gcovr developer here. Gcovr does not currently create .gcov reports. So using the
gcovr --sonarqube output format is the only supported option to connect our respective tools.
Both XML formats (SonarQube and Cobertura) provide equivalent information. If necessary, it is possible to generate multiple reports in one go, e.g.:
gcovr OPTIONS --sonarqube sonar.xml --xml cobertura.xml
If raw .gcov files are desired, it would be necessary to run
gcov manually (without gcovr). The
-l/--long-file-names option should be used to get correct coverage information in header files, and either
-p/--preserve-paths if multiple source files have the same base name.
@latk thanks for clarifying — I didn’t quite realise the distinction between gcov and gcovr. Really appreciate it!