Code Coverage Metrics not same % Azure DevOps - SQ

I run a CI pipeline for a dotNet app

  • CI system used
    Azure DevOps server on prem SQ 9.8
    Code coverage configured and I get different results on both sides
    when I check coverage in the Azure Devops build summary I see coverage percentage which is 44.4% (949 of 2134)

whereas In SQ, I 58.3%

I see same number of uint tests on both sides

Here is the config of the SQ prepare task in the pipeline

t

ask: SonarQubePrepare@5
  enabled: true
  inputs:
    SonarQube: 'SQGlobalConn'
    scannerMode: 'MSBuild'
    projectKey: 'ps-presidents-ci-vsComm'
    projectName: 'ps-presidents-ci-vsComm'
    extraProperties: |
      sonar.cs.vstest.reportsPaths= $(Build.Repository.LocalPath)/test/*Tests/TestResults/*.trx
      sonar.cs.vscoveragexml.reportsPaths=$(Common.TestResultsDirectory)/myfile.coverage.xml
      sonar.dependencyCheck.securityHotspot=true
      sonar.dependencyCheck.jsonReportPath=$(System.DefaultWorkingDirectory)/dependency-check-report.json
      sonar.dependencyCheck.htmlReportPath=$(System.DefaultWorkingDirectory)/dependency-check-report.html
      sonar.coverage.exclusions = **/*.js,**/*.json,**/*.xml,**/*.png,**/*.sh,**/*.h,**/*.m,**/*.c,**/*.cpp,**/*.pdf,**/*.plist,Pods/**/*
      sonar.swift.excludedPathsFromCoverage=.*Tests.*

I went through a thread here at

Code Coverage Metrics not matching Azure DevOps - SonarCloud - Sonar Community (sonarsource.com)

but not sure I understand what I need to do more that the config I have so I woued eike to see same resuets on both sides

Hi,

It’s not often that someone complains their coverage is higher in SonarQube :joy:.

Since we rely on the the coverage reports you feed in to know what’s covered/not covered in a file, this is more than likely about which files go into the denominator. I suspect you’ve got an exclusion either in your analysis parameters/switches or in the UI. Before we working on finding where it’s set, you can confirm that it is set by going to Project Settings → Background Tasks → [most recent ‘Success’ row] → [cog menu] → Show Scanner Context to see the properties that analysis ran with.

 
Ann