--output-dir : Specifies where the resulting files (including test-result-codecoverage.json ) are stored. 2. Querying the Tooling API (For Custom Reports)
Stores coverage details per individual test method. Example SOQL Query: download code coverage results salesforce
Run the following command to execute tests and save the coverage results into a specific directory: Example SOQL Query: Run the following command to
For teams that need a "one-click" Excel or PDF export without writing code, several tools are available: apex Commands | Salesforce CLI Command Reference red for uncovered)
If you need specific data to build your own report, you can query Salesforce objects via the Tooling API .
While the Salesforce Developer Console allows you to view coverage visually (blue for covered, red for uncovered), it does not offer a native "Export" button for those results. Instead, developers typically rely on the following professional methods to retrieve this data for audits or CI/CD pipelines. 1. Using Salesforce CLI (Recommended for Developers)
sf apex run test --code-coverage --result-format human --output-dir ./coverage-results Use code with caution.