Coverage exclusion

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Version 8.9.2 (build 46101)
  • what are you trying to achieve
    I am trying to exclude a particular class from code coverage.
  • what have you tried so far to achieve this
    To do so I am adding the class and header under sonar.coverage.exclusions in the file BUT the sonar cube report still flags it for lack of coverage.
    In Narrowing the focus article (Narrowing the Focus | SonarQube Docs) it only mentions the example through the UI project settings. I was wondering is sonar.coverage.exclusions actually the right way to go? I do not want to completely exclude the file from analysis altogether, just coverage.


Yes, you want to set up a coverage exclusion for the file, not an overall exclusion. And yes, the UI is the recommended way to do this.