.Net Code Coverage not shown on SonarCloud

I’m trying to publish code coverage results to SonarCloud using the SonarCloud Scan Action on a GitHub repository like this:

- name: SonarCloud Scan
  uses: sonarsource/sonarcloud-github-action@master
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  with:
    args: >
      -Dsonar.organization=raschmitt
      -Dsonar.projectKey=raschmitt_stryker-net-sample
      -Dsonar.sonar.cs.opencover.reportsPaths=**/*.opencover.xml

Coverage report is being generated in opencover format, using Coverlet:

- name: Test
  run: coverlet bin/Debug/netcoreapp3.1/Stryker.Net.Sample.Tests.dll -t dotnet -a "test --no-build" -f opencover
  working-directory: Stryker.Net.Sample/Stryker.Net.Sample.Tests

My action is using Stryker.Net.Sample as base directory, and reports are being placed under Stryker.Net.Sample/Stryker.Net.Sample.Tests/coverage.opencover.xml

Everything seems to bee fine, and my action runs with no problems, yet I can’t see any coverage results on SonarCloud.

What am I doing wrong here?

Hi @raschmitt and welcome to the community !

Do you see your source code properly on SonarCloud’s dashboard ?

Yes I can see it just fine.

I ended up migrating to Azure Devops pipelines, where it worked fine with the official plugin.

1 Like