Apex test code coverage report is not picking rightly in sonarqube

sfdx-apex-test-run-coverage report which differs from the SonarQube and failing the CI job.


Current sfdx version: sfdx-cli/7.120.0 win32-x64 node-v14.18.0

As per image shows above, getting wrong output in the test summary results(100%) as actually, the main required class is having only 72%. I am not sure why test results summary shows wrongly and also several other test classes are considered and showing in the detailed report while running the command
sfdx force:apex:test:run --testlevel RunSpecifiedTests --tests “XXXXXXImageTriggerHandlerTest” --outputdir testReport --codecoverage -r human -y -w 20

While importing these test results report to the sonarqube code analysis tool for the code coverage through SonarQube, its still throwing new lines of code coverage is lesser %
sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.apex.coverage.reportPath=**/testReport/test-result-codecoverage.json
How can we consider the SFDC test code coverage into the SonarQube code coverage for the lines of code as SonarQube covers either new lines of code or Overall code in a project. But Is there any possibility of checking the codecoverage at Overall class level like how it considers in the SFDC code coverage instead of Overall code in application

Pls let me know your suggestions and Thanks for your time and appreciate your support.


Hi Bala,

This is outside the scope of this community.

That’s probably due to executable lines.

Metrics are available below the project level through the Measures and Code menu items. Just drill down in either place to the level/file of interest.