DEV Community

Aellon
Aellon

Posted on

1 1

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!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more