ALM used
GitLab
CI system used
GitLab CI (2-stage pipeline: Test Run stage → Sonar Scan stage)
Scanner command used
Bash
# Stage 1: Generate coverage
sf apex run test $TEST_ARGS \
--code-coverage \
--wait 60 \
--result-format json \
--output-dir ./test-results \
--concise \
--target-org dev
# Stage 2: SonarCloud Scan
sonar-scanner \
-Dsonar.organization=***** \
-Dsonar.projectKey=***** \
-Dsonar.sources=force-app \
-Dsonar.apex.coverage.reportPath=./test-results/test-result-codecoverage.json
Languages of the repository
Apex, SFCC
SonarCloud Project URL
Private Project
Error observed
SonarCloud displays 0% code coverage for multiple Apex classes across the project, despite tests running successfully and high coverage being recorded in the generated coverage report.
For example, AGCX_AuthCartPricingHelper.cls shows 98% coverage in the Salesforce Sandbox and 99% coverage inside the generated ./test-results/test-result-codecoverage.json report, but SonarCloud reports 0%.
refer attached snippets
Relevant test-result-codecoverage.json snippet:
JSON
[
{
"apexId": "01pXXXXXXXXXXXXXXX",
"name": "AGCX_AuthCartPricingHelper",
"type": "ApexClass",
"numLinesCovered": 180,
"numLinesUncovered": 2,
"percentage": "99%"
}
]
Steps to reproduce
-
Run Apex unit tests using
sf apex run testwith--code-coverageand--result-format json. -
Save the output to
./test-results/test-result-codecoverage.json. -
Pass
sonar.apex.coverage.reportPath=./test-results/test-result-codecoverage.jsonto the SonarCloud scanner step. -
Check SonarCloud dashboard — coverage reports 0% across multiple classes.

