Hi, I integrated the sonar cloud with Azure DevOps. C# I run tests, publish code coverage in the Azure pipeline and pass XML files in Sonarcoud. but my local coverage report is 75% and Azure pipeline code coverage is also 75% but the sonar cloud shows 68% I am using OpenCover.xml sonar.cs.opencover.reportsPaths=“/agent/_work/_temp/**/coverage.opencover.xml” how we match % of result
I suggest that you start by finding a specific discrepancy between SonarCloud and the OpenCover / Azure DevOps report (a specific line/file where the coverage reports don’t match), and bring the results here (screenshots are a great way to display the issue)
SonarCloud’s coverage metric is ultimately a combination of Line Coverage and Condition Coverage (documented here
coverage) It is a mix of line coverage and condition coverage. Its goal is to provide an even more accurate answer to the following question: How much of the source code has been covered by the unit tests?
Coverage = (CT + CF + LC)/(2*B + EL)where
- CT = conditions that have been evaluated to ‘true’ at least once
- CF = conditions that have been evaluated to ‘false’ at least once
- LC = covered lines = lines_to_cover - uncovered_lines
- B = total number of conditions
- EL = total number of executable lines (
This probably explains part of the discrepancy between 76% (line coverage reported by azure devops) and the 70% overall coverage reported by SonarCloud.
That still leaves a 2.4% difference in line coverage, and I have to insist that you find a specific discrepancy in order to troubleshoot further.