Coverage exclusion not working

I’m trying to add two coverage exclusion rules and they work independently but not together. The first is intended to filter all files that end in “ControllerDocumentation.cs” and the second is intended to filter all files that fall under folders that start with “MyProject.Tests”. The config looks like:

sonar.coverage.exclusions="**/*ControllerDocumentation.cs, **/MyProject.Tests*/**/*"

Any advice?

Hi Alex, and sorry for the late reply,

did you manage to fix your problem? Looking quickly at your setting, this should be working fine.

What fixed it for me was using the web client for the configuration. However, I’d really like to be able to handle it as a part of my CI scripts so it could be version controlled. Would be happy to work with you to get that figured out.

How do you configure this property in your CI scripts? This must definitely be possible to achieve what you want Alex.

We’re using command line configuration. The only thing that’s special is we’re using Azure Pipelines. I haven’t tried running the console runner myself manually. The reason I don’t think Azure Pipelines is the issue is because if I just do one or the other pattern it works fine. I’m inferring that Azure Pipelines is transparently passing those values in but that may not be true.

The yaml definitions look something like:

steps:
  - task: SonarSource.sonarcloud.some-guid
    displayName: 'Prepare analysis on SonarCloud'
    inputs:
      SonarCloud: 'the_project'
      organization: the organization
      projectKey: theProjectKey
      projectName: TheProjectName
      extraProperties: |
        sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)\coverage-reports\coverage.xml"
        sonar.coverage.exclusions="**/*ControllerDocumentation.cs, **/MyProject.Tests*/**/*"

So if I understand well, the following works:

sonar.coverage.exclusions="**/*ControllerDocumentation.cs"

And this works too:

sonar.coverage.exclusions="**/MyProject.Tests*/**/*"

But not when you combine both, it that right?

Sorry for the delay response.

Yes. That’s it exactly. If I put them into 1 comma-delimited string then neither of them work.

@Alex_Denton, if you do this, does it work:

sonar.coverage.exclusions=**/*ControllerDocumentation.cs,**/MyProject.Tests*/**/*

You mean removing the quotes? I’m pretty sure I tried that but I can give it a go when I’m back at my desk.