3

In our org we have setup SonarQube with codescan. The build is triggered through a Jenkins job.

Now we are struggling to get data from the coverage. eventhough we are setting the resultformat to json in sfdx force:apex:test:run My output directory is named coverage in my sonar-project.properties I have mentioned the directory to the test-result-codecoverage.json.

sonar.language=Apex
sonar.projectBaseDir=.
sonar.apex.coverage.reportPath=coverage/test-result-codecoverage.json

But in some way the coverage value is always 0. Does someone know how sonarqube can parse my unit test report from sfdx.

2
  • Salesforce DX does not output a standard format like Cobertura or Lcov. Have you confirmed that with your vendor that SonarQube supports SFDX's unique coverage format?
    – David Reed
    Commented Jun 15, 2020 at 18:31
  • @DavidReed I have confirmed SonarQube supports sfdx format (json) out of the box. It seems that sonarqube can't access the directory I made for the test coverage
    – RomeoRomeo
    Commented Jun 15, 2020 at 18:35

1 Answer 1

0

Feel free to use my Salesforce CLI plugin if your Apex is imported into a Git repo following the Salesforce DX structure - https://github.com/mcarvin8/apex-code-coverage-transformer

This plugin will convert the code coverage JSON files created during deployments (sf project deploy) and test runs (sf apex test run) into a coverage XML that SonarQube accepts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .