
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
apex-code-coverage-transformer
Advanced tools
Transforms the Apex Code Coverage JSON into the Generic Test Data Report.
The apex-code-coverage-transformer is a simple Salesforce CLI plugin to transform the Apex Code Coverage JSON file into Generic Test Coverage Format (XML). This format is accepted by static code analysis tools like SonarQube.
This plugin supports code coverage metrics created for Apex Classes, Apex Triggers, and Flows (if flows are deployed as active in your org). This also supports multiple package directories as listed in your project's sfdx-project.json configuration, assuming unique file-names are used in your package directories.
To create the code coverage JSON during a Salesforce CLI deployment/validation, append --coverage-formatters json --results-dir coverage to the sf project deploy command:
sf project deploy validate -x manifest/package.xml -l RunSpecifiedTests -t {testclasses} --verbose --coverage-formatters json --results-dir coverage
This will create a coverage JSON in this relative path - coverage/coverage/coverage.json
This JSON isn't accepted by SonarQube automatically and needs to be converted using this plugin.
Note: This has been tested and confirmed on code which meets 100% coverage.
sf plugins install apex-code-coverage-transformer@x.y.z
The apex-code-coverage-transformer has 1 command:
sf apex-code-coverage transformer transformRecommend running this command in the same directory that your sfdx-project.json file is located in. This command will use the packageDirectories in the JSON file to set the file-paths in the coverage file.
sf apex-code-coverage transformer transformUSAGE
$ sf apex-code-coverage transformer transform -j <value> -x <value> -c <value> [--json]
FLAGS
-j, --coverage-json=<value> The path to the JSON file created by the Salesforce CLI for code coverage.
-x, --xml=<value> [default: coverage.xml] Output path for the XML file created by this plugin
-c, --sfdx-configuration=<value> [default: 'sfdx-project.json' in the current working directory] The path to your Salesforce DX configuration file, 'sfdx-project.json'.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
This plugin will convert the JSON file created by the Salesforce CLI during Apex deployments into the Generic Test Coverage Format.
EXAMPLES
$ apex-code-coverage transformer transform -j "test.json" -x "coverage.xml" -c "sfdx-project.json"
This code coverage JSON file created by the Salesforce CLI will be transformed into:
<?xml version="1.0"?>
<coverage version="1">
<file path="force-app\main\default\triggers\AccountTrigger.trigger">
<lineToCover lineNumber="52" covered="false"/>
<lineToCover lineNumber="53" covered="false"/>
<lineToCover lineNumber="59" covered="false"/>
<lineToCover lineNumber="60" covered="false"/>
</file>
<file path="force-app\main\default\classes\AccountProfile.cls">
<lineToCover lineNumber="52" covered="false"/>
<lineToCover lineNumber="53" covered="false"/>
<lineToCover lineNumber="59" covered="false"/>
<lineToCover lineNumber="60" covered="false"/>
</file>
<file path="force-app\main\default\flows\Get_Info.flow-meta.xml">
<lineToCover lineNumber="52" covered="false"/>
<lineToCover lineNumber="53" covered="false"/>
<lineToCover lineNumber="59" covered="false"/>
<lineToCover lineNumber="60" covered="false"/>
</file>
</coverage>
FAQs
Transform Salesforce Apex code coverage JSONs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.
The npm package apex-code-coverage-transformer receives a total of 2,553 weekly downloads. As such, apex-code-coverage-transformer popularity was classified as popular.
We found that apex-code-coverage-transformer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.