Introduction

This extension shows a summary of the code coverage for all APEX classes in the current project. The extension relies on the official Salesforce Extensions test runner which creates the necessary files used to show the code coverage.

It works with both Dark and Light themes

Documentation

Make sure you have configured the preferences on the Salesforce extension to retrieve code coverage on test execution. To do this, go to Visual Studio Code menu File->Preferences->Settings and enter “coverage” in the search box, and then from the search results enable the Retrieve-test-code-coverage setting:

After that, just execute some tests as you normally would from the Test view:

Once the test coverage has been downloaded by the Salesforce CLI, you can now see the code coverage for a specific Apex file in the status bar, and also the overall code coverage in a new window:

Coverage in Status Bar

The indicator in the status bar will only appear if the Apex class has tests coverage downloaded for such class. You can see three indicators, depending on the coverage percentage:

Coverage Indicator

0% – 65%

65% – 75%

75% – 100%

Coverage Window

You can get to this window by either clicking on the coverage indicator on the status bar, or by executing the SFDX: Show Code Coverage from the command palette:

Filtering

It is possible to filter down the test results to show only tests that are below the required 75% coverage, to allow the developer to focus on those tests that require inmediate action. Also, it is posible to filter further down on the name of the apex file:

Bugs and Feedback

To report issues with Salesforce Extensions for VS Code, open a bug on GitHub. If you would like to suggest a feature, create a feature request on GitHub.

Please click here to read the original article as posted on Visualstudio.

We source the web to bring you best Salesforce articles for our reader’s convenience. If you want to have this article removed, please follow guidelines at Digital Millennium Copyright Act (DMCA)..

LEAVE A REPLY

Please enter your comment!
Please enter your name here