Exclude test folder from Code Coverage

SonarQube Version - 7.3
I want to get code coverage for my project but the code coverage is also including the test folder for coverage so my percentage is going low.

What I mean is I want to exclude test folder from code coverage percentage.

I am working in java


The contents of your tests directory are being included in the coverage calculation because SonarQube thinks they’re source files (not test files). The first line of defense here is to edit the value of sonar.sources to not include that directory.

If your response is that you included it in sonar.sources because you want rules applied to it, then you’ll need to set up a Coverage Exclusion for it.


Where do I configure this sonar.sources?


How do you analyze/with which scanner?


I have a similar problem: If i don’t include tests folder in the sonar source, or if i exclude the tests , sonar is telling me that there is no tests coverage. But if i include them it is telling me that those tests file are not properly covered. I’ve tried a bunch of tweaks but without luck so far.
I’m seeing this on a python 3.6 project.

Similar problem here, im using jacoco plugin to generate test results. i also have javascript code in the same project so i excluded all unnecessary files like this:


but frontend/fileName***.js keeps showing up in the sonarqube coverage analysis.

Hi @Francis_Joseph,

Welcome to the community!

To be clear, ** matches 0-n directories. I think what you want is: **src/test/**/*.*