I am executing code coverage through SFDX cli, below is the command:
sfdx force:apex:test:run --targetusername $username --resultformat json --codecoverage --testlevel RunLocalTests
I then upload the report in sonarqube.
I see 2 results on console:
1) testruncoverage --> It is 28%. 2) orgwidecoverage --> It is 34%.
"testruncoverage --> It is 28%" is the one that gets posted on SonarQube.
What is the difference between those 2? How do I make testRunCoverage and orgWideCoverage as same? How do I show orgWideCoverage on sonarqube?
Should I be running it as "--testlevel RunAllTestsInOrg"
RunLocalTests
will run all tests in an org except managed packages. If you change toRunAllTestsInOrg
that will include the managed packages. See the sfdx CLI reference.