I have a C++ project that is configured as follows:
sonar.sources=src
sonar.exclusions=**/*.json, **/*.py, **/*.js, **/*.xml, **/*.html
src/
folder internally contains source code for several libraries and their unit tests.
I would like to enforce code quality rules on the unit test sources but to exclude them from the code coverage calculation. The reason for exclusion is that I’m not generating/collecting coverage data for the unit tests so all test sources appear with 0 coverage in SonarCloud and significantly reduce overall coverage.
From this I understand that I can not use sonar.tests
to distinguish between the real project sources and the test sources.
If you wish to analyze test source files, you should include them in the
sonar.sources
property.
How can I achieve my goal? I would like to avoid collecting coverage metrics for the test sources if possible.