I want to exclude our test classes from sonar scan, for which I added property “sonar.exclusions=src/test/**” in my pom.xml but sonar is still scanning and reporting issues in that folder. I tried different pattern like /test/ etc. How can I exclude this folder from scan.
We are using SonarQube version 9.9 and Java version11
You don’t need to exclude your test files. If you are using SonarScanner for Maven (if you have a pom.xml file then you should use it) they will be automatically excluded from the main sources and will be analyzed as test code with a set of different rules (yes, tests are sources that should be analyzed as well).
Take a look at specific rules for tests code here: