SonarCloud showing 0.0% Code Coverage

Hello,

We use SonarCloud in our pipeline to analyse the code of our projects. We use coverlet for code coverage and have had a number of issues with the Quality Gate failing so I have recently updated our .runsettings to include only our controllers/endpoints. After pushing through the changes and running the pipeline, coverlet is showing as 0.0% code coverage and seems to list all of our files, including those that should be excluded.

Coverage0

Our pipeline executes the code coverage with the following code:

# Run 'Admin.Api' unit tests.
          - task: DotNetCoreCLI@2
            displayName: 'Run Admin.Api unit tests'
            inputs:
              command: 'test'
              majorVersion: 8
              minorVersion: 0 
              projects: '**/Admin/**/*.UnitTests.csproj'
              arguments: '--configuration $(buildConfig) --collect:"XPlat Code Coverage" --settings $(System.DefaultWorkingDirectory)/src/Services/Admin/Admin.UnitTests/.runsettings'

          # Run 'Identity.Api' unit tests.
          - task: DotNetCoreCLI@2
            displayName: 'Run Identity.Api unit tests'
            inputs:
              command: 'test'
              majorVersion: 8
              minorVersion: 0 
              projects: '**/Identity/**/*.UnitTests.csproj'
              arguments: '--configuration $(buildConfig) --collect:"XPlat Code Coverage" --settings $(System.DefaultWorkingDirectory)/src/Services/Identity/Identity.UnitTests/.runsettings'

Azure is showing our code coverage correctly:

We have also got a warning from SonarCloud telling us: “There were parsing errors in 1 files while analyzing the project. Check the logs for further details.”

We have attempted to find the logs it mentioned but have had no luck. We think it’s in Background Tasks but can find no logs option.

Hi,

Welcome to the community!

There are multiple things going on here:

  • Missing coverage
  • Ignored exclusions
  • Parsing errors

We try to keep it to one topic per thread. Otherwise it can get messy, fast. Since your primary concern seems to be coverage, let’s concentrate on that.

You’ve provided the pipeline steps for generating your coverage report, but not their larger context, E.G.. So: how are you passing the reports in to analysis?

And can you provide the CI-side analysis logs?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann