README
apex-coverage
A Salesforce CLI plugin to work with apex code coverage obtained by sfdx force:apex:test:run -r human --codecoverage --outputdir <path>
.
To install
$ sfdx plugins:install apex-coverage
$ sfdx force:apex:test:coverage -h
...
For CI/CD, add the plugin to the unsignedPluginWhiteList.json file.
echo '["@salesforce/plugin-apex-coverage"]' > ~.config/sfdx/unsignedPluginWhiteList.json
Note: This will override an existing unsignedPluginWhiteList.json file.
sfdx force:apex:test:coverage:format -c <filepath> [-f <array>] [-o <directory>] [--apexsourcedir <directory>] [-t <number>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
converts apex code coverage to a different coverage format
USAGE
$ sfdx force:apex:test:coverage:format -c <filepath> [-f <array>] [-o <directory>] [--apexsourcedir <directory>] [-t
<number>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-c, --coverage=coverage (required) filepath to the apex json
coverage file produced by
force:apex:test:run
-f, --coverageformats=coverageformats [default: clover] an array of new
coverage formats
[clover,json,json-summary,lcov,lcovo
nly,cobertura,html]
-o, --outputdir=outputdir [default: (current directory)]
directory to store the new results
folder
-t, --threshold=threshold [default: 0.75] the code coverage
threshold
--apexsourcedir=apexsourcedir [default: (current directory)] the
apex source directory (all inner
folders will be searched)
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
EXAMPLE
$ sfdx force:apex:test:run -w 10 -c -r human -d test-reports
...
$ sfdx force:apex:test:coverage:format -c test-reports/test-result-codecoverage.json
Wrote results to <path>/clover