Hello everyone. In this video, we are
going to see how to check Apex code uh
uh test code coverage in Visual Studio
Code Editor for Salesforce development.
I'm not going to talk about Apex unit
testing and Apex code coverage. In this
video, we are going to quickly see how
to execute a test class and how to check
the code coverage. Usually, we make use
of Salesforce developer console and see
how much the code is covered. The
covered code will be in different color
and the uncovered code will be in
different colors. If you wanted the same
developer console experience in Visual
Studio Code Editor, then you can make
use of this video as your reference.
First, let's see a demo and then we will
see what configurations we have to
enable in the Visual Studio Code to
achieve this.
So, I'm going to run a test class.
So I'm going to run all tests in this
particular test class. It is executing.
Okay, it got executed. Now if I open the
class,
I should be able to see
they call this as amber icon also
sometimes.
So if you make use of this uh
icon highlight Apex code coverage then
it will display
the same developer console experience
for you. The code that are highlighted
in green are covered uh um under the
Apex uh um test coverage. The ones that
are not covered will be highlighted in
red color.
So we were able to have the same
developer console experience in the
Visual Studio Code.
In order to achieve it,
go to
settings
in your Visual Studio Code and search
for retrieve- test code- coverage.
Once you search enable Salesforce DX -
VS code - Apex - testing retrieve test
code coverage option. Once you enable
it, if you're unable to see this uh
highlight Apex code coverage icon, quit
the VS Code and uh reopen it again. Then
you should be able to see it.
Make sure this option is enabled so that
you can have the same developer console
experience in the Visual Studio Code
editor.
I hope it was helpful.
Thank you for watching.