Pull Request Code Coverage for .NET 6 C# in BitBucket

I was assigned a task to update our SonarCloud reports to show Code Coverage on pull requests and I haven’t yet been able to get it working.

Our project:

  • .NET 6 MVC (C#)
    • We have separate projects for “UseCases” which contain our business logic.
    • We have a “UseCases.Tests” project which contains the unit tests for those UseCase classes.
  • Repository and pipelines are in BitBucket

The sonarscanner report does show up in the pull requests, however “Coverage” is always empty.

I’ve tried a few variations of the pipeline yaml, but I have yet to see anything show up under “Coverage”.

Currently, our yaml looks like this (I have a commented-out section above containing one of my other attempts)

Please forgive the fact that I don’t have a ton of experience with SonarScanner and I’m not very familiar with code coverage reporting in general (namely the various report formats). I also didn’t create the initial setup for SonarCloud, so there MAY be configurations in the Administrator side of SonarCloud that could theoretically be breaking things but I’m not seeing anything obvious.

I’m wondering if there’s something obvious I’m missing…

Thank you!

Hey there.

Take a look at this thread.