How to make Sonar ignore some classes for codeCoverage metric?

后端 未结 8 1948
花落未央
花落未央 2020-12-08 09:18

I have a Sonar profile in Maven. Everything works fine except the code coverage metric. I want to make Sonar ignore some classes only for the code coverage metric. I have th

8条回答
  •  暖寄归人
    2020-12-08 09:42

    I had to struggle for a little bit but I found a solution, I added

    -Dsonar.coverage.exclusions=**/*.* 
    

    and the coverage metric was cancelled from the dashboard at all, so I realized that the problem was the path I was passing, not the property. In my case the path to exclude was java/org/acme/exceptions, so I used :

    `-Dsonar.coverage.exclusions=**/exceptions/**/*.*` 
    

    and it worked, but since I don't have sub-folders it also works with

    -Dsonar.coverage.exclusions=**/exceptions/*.*
    

提交回复
热议问题