As per answer in this post, in order to get code coverage after running test classes from VSCode, we just need to add "-c" for the sfdx test command as below:

 sfdx force:apex:test:run -c -u myOrg -r human

I have added

salesforcedx-vscode-core.retrieve-test-code-coverage": true

to my User Settings to be set as default.

Even though I can get the code coverage in the Output tab, showing the percentage + uncovered lines numbers, I haven't been able to see a visual representation for each class which lines have been hit or not.

This is what we get after running the tests:

    ID                  NAME                                 % COVERED           UNCOVERED LINES
──────────────────  ───────────────────────────────────  ──────────────────  ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
01p0d000000kCOcAAM  TaskManager                         75%                 66,67,72,74,75,78,79,82,86,87,89,93,97,100,102,105,106,111,114,119,120,123,125,128,129,130,134,135,140,143,144,145,148,193,243,246,248,251,253,257,260,262,265,267,271,274,276,421,461,474,486

Does anybody know is it's possible to get code coverage like we get in Developer Console or like the "coverage-gutters" plugin for VSCode, after running Apex Tests?

enter image description here


2 Answers 2


In VS Code in your DX project, try clicking the three horizontal lines icon in the bottom status bar. If you have all the configurations setup correctly (which from your post, it looks like you do), clicking it from enter image description here to enter image description here should work

For completeness: the only configuration change that you have to do is enable code coverage in "File -> Preferences -> Settings", search for the setting "Salesforcedx-vscode-core: Retrieve-test-code-coverage" and enable it

Update Oct 2020

🚀 There's a new video from the Salesforce Developers channel in YouTube that literally walks you through enabling VS code coverage highlighting from start to finish.

  • Awasome tip. Thnx
    – Rahul
    Feb 21, 2020 at 12:59
  • 4
    As Brian mentioned, visual code coverage works out-of-the-box in VS Code, but do remember to enable code coverage in "File -> Preferences -> Settings", search for the setting "Salesforcedx-vscode-core: Retrieve-test-code-coverage" and enable it Feb 28, 2020 at 14:49
  • @OscarScholten Please post your comment as an answer since yours should be the best answer, Thanks a lot!!
    – Bahman.A
    Mar 9, 2020 at 23:29
  • 2
    Cna't say I've ever noticed that icon, let alone assumed it was somehow related to dx or test coverage!
    – Matt Lacey
    Nov 17, 2020 at 9:39
  • 1
    Genius level! Had it all installed but still was using Dev Console to view coverage in color since I overlooked that icon. Thanks.
    – skycafe
    Jan 13, 2021 at 5:58

You can get the code coverage as in Developer Console (code coverage for each test method) with this extension.

Disable retrieve-test-code-coverage from settings if you use it.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .