How to Check Salesforce Apex Code Coverage in Visual Studio Code: A Step by Step Guide
Feb 5, 2026
Show More Show Less
View Video Transcript
0:08
Hello everyone. In this video, we are
0:11
going to see how to check Apex code uh
0:15
uh test code coverage in Visual Studio
0:18
Code Editor for Salesforce development.
0:22
I'm not going to talk about Apex unit
0:25
testing and Apex code coverage. In this
0:27
video, we are going to quickly see how
0:30
to execute a test class and how to check
0:33
the code coverage. Usually, we make use
0:36
of Salesforce developer console and see
0:40
how much the code is covered. The
0:42
covered code will be in different color
0:45
and the uncovered code will be in
0:47
different colors. If you wanted the same
0:50
developer console experience in Visual
0:53
Studio Code Editor, then you can make
0:55
use of this video as your reference.
0:58
First, let's see a demo and then we will
1:00
see what configurations we have to
1:02
enable in the Visual Studio Code to
1:04
achieve this.
1:07
So, I'm going to run a test class.
1:14
So I'm going to run all tests in this
1:16
particular test class. It is executing.
1:24
Okay, it got executed. Now if I open the
1:27
class,
1:29
I should be able to see
1:33
they call this as amber icon also
1:36
sometimes.
1:38
So if you make use of this uh
1:42
icon highlight Apex code coverage then
1:45
it will display
1:47
the same developer console experience
1:49
for you. The code that are highlighted
1:52
in green are covered uh um under the
1:55
Apex uh um test coverage. The ones that
2:01
are not covered will be highlighted in
2:03
red color.
2:05
So we were able to have the same
2:07
developer console experience in the
2:09
Visual Studio Code.
2:12
In order to achieve it,
2:15
go to
2:17
settings
2:18
in your Visual Studio Code and search
2:21
for retrieve- test code- coverage.
2:28
Once you search enable Salesforce DX -
2:33
VS code - Apex - testing retrieve test
2:38
code coverage option. Once you enable
2:41
it, if you're unable to see this uh
2:45
highlight Apex code coverage icon, quit
2:48
the VS Code and uh reopen it again. Then
2:52
you should be able to see it.
2:55
Make sure this option is enabled so that
2:57
you can have the same developer console
3:00
experience in the Visual Studio Code
3:02
editor.
3:09
I hope it was helpful.
3:20
Thank you for watching.
#Internet Software
