1

We are working on SonarQube code coverage, We are using Salesforce CLI for generating the code coverage result and we are importing that result in the SonarQube.

We see that there is a difference in Result that we see on Salesforce UI and JSON file

Salesforce UI shows 85% SonarQube shows 55%

We followed the Link https://help.salesforce.com/articleView?id=000335222&type=1&mode=1 and cleared the history but still, we are facing the issue.

please suggest if anyone came across the same issue

2
  • Is there a difference in whether tests are run sequentially or in parallel between the two? Parallel execution of tests can cause a race condition on code coverage detail capture, losing some information along the way.
    – Phil W
    Jun 12, 2020 at 10:17
  • Hi, @PhilW Thank you for your response. The tests are not running parallelly, We have Disabled the parallel execution.
    – Spande
    Jun 12, 2020 at 10:54

1 Answer 1

0

There are changes done by Salesforce, as mentioned in following blog

https://developer.salesforce.com/blogs/2021/04/clearer-apex-commands

test-result-codecoverage.json

This file displays information for each Apex class covered by the test methods that were run. There’s no change to the format of this file. The data only includes relevant information now. (Similar to the changes described above for the human-readable output) The only classes listed in this file will be ones that are directly touched by the tests that were run. The information comes from the ApexCodeCoverageAggregate entity.

We are also facing this issue, when we checked detail coverage test-result-<>.json, number of entries coverage is 10000. As a result, only subset of files are included in test-result-codecoverage.json which are touched by 10000 entries in coverage test-result-<>.json

Does anyone found any solution, one possible solution could be extract data from ApexCodeCoverageAggregate and transform that to create test-result-codecoverage.json and pass that to SonarQube.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.