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!

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay