Code Exclusions for Code Coverage Stats

  • ALM used:Azure DevOps
  • CI system used: Azure DevOps
  • Languages of the repository: C#

I’m looking to clarify the correct why to setup code exclusions for code coverage stats.
Currently we set this up in our .runsettings file so we can declare which namespaces should and shouldn’t be regarded as eligible for testing so typically we’d exclude non-functional things like models, mappers, data migrations etc.
When our tests and the resulting coverage stats are produced (from our our CI pipeline) from this we’re getting good coverage results > 70%. However, after the SonarCloud analysis and when the data is published to SonarCloud it seems unaware of all the exclusions we’ve created and looks at coverage for the entire repo resulting in really poor coverage results < 20%. Is this expected? Should we be replicating our exclusions using the Coverage Exclusions (sonar.coverage.exclusions)

Hey there.

.runsettings files are not honored, and the exclusions must be replicated in sonar.coverage.exclusions

1 Like