DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Aellon
Aellon

Posted on

How to View Apex Code Coverage in VS Code

This is a summary of instructions for how to view unit test coverage in VS Code as an alternative to using Salesforce’s Developer Console. The official guide, Apex Tests | Salesforce for VSCode is a great resource, but this post also includes a video walkthrough.

Instructions

  1. In VS Code click Code > Preferences > Settings and search for Apex Coverage.

  2. Set salesforcedx-vscode-core.retrieve-test-code-coverage to true by checking the box of that setting.

  3. Click the beaker icon in the Activity Bar on the left side of the VS Code editor and run a test or multiple tests. The coverage percentage and lines that were not covered by the test run will show in the output panel.

  4. To see code coverage for your test, click the three-bars icon that’s next to your Org alias at the bottom of VS Code and open the class or trigger that you’re testing. Click the the three-bars icon to toggle between enabling and disabling code coverage highlighting.

A video walkthrough:


Do you prefer to review test coverage in the developer console or VS Code? Let me know in the comments!

Top comments (0)

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.