Exclude test folder from Code Coverage


(Prashant Verma) #1

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


(G Ann Campbell) #2

Hi,

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.

 
Ann


(Prashant Verma) #3

Where do I configure this sonar.sources?


(G Ann Campbell) #4

Hi,

How do you analyze/with which scanner?

 
Ann