Testing Agentforce Agents from VS Code
13K views
Jul 7, 2025
When working with Agentforce Development, thoroughly testing your agents is crucial for ensuring their reliability and effectiveness. Agentforce DX provides a streamlined method for executing these tests. Blog Post: https://www.infallibletechie.com/2025/07/testing-agentforce-agents-from-vs-code.html
View Video Transcript
0:07
Hello everyone. In this video, we are
0:10
going to see how to test Salesforce
0:14
agent force agents from Visual Studio
0:18
Code.
0:21
As part of agent force agents
0:24
development, it is crucial to test the
0:28
agent force agents
0:30
regularly as we do some changes to the
0:34
agents.
0:37
The prerequisite to test Salesforce
0:40
agent force agents from VS code are we
0:44
have to install VS code. So you can make
0:47
use of this uh link. you can go to the
0:50
VS code uh website and then you can
0:53
download it and install it based on your
0:57
OS version. If you are using Windows,
0:59
you have to download it. Uh you you have
1:02
to download the .exe file. Um and if you
1:06
are going to use Mac OS, then you have
1:08
to download the package accordingly.
1:12
The next step is we have to install
1:15
Salesforce extension pack within the VS
1:18
code. You can use this link and then you
1:21
should be able to
1:23
install Salesforce extension pack
1:28
from the VS code marketplace.
1:32
Next, we have to install agent force DX
1:36
VS code extension. So, you can use this
1:39
link and then you should be able to
1:41
install it. If you are using uh code
1:44
builder then you have to use this link
1:46
and then you have to do it. As part of
1:49
this video we are going to use the VS
1:52
code uh uh in the Mac OS and we are not
1:56
going to make use of code builder.
1:59
Next install Salesforce command line
2:01
interface.
2:03
Make sure it is up to date.
2:08
If you wanted uh uh to set up a
2:11
Salesforce uh uh project then you can
2:14
make use of these two links.
2:17
You can make use of these two links so
2:19
that you will be able to set up
2:20
Salesforce uh project for the
2:22
development in your VS code.
2:28
The first step is we have to make sure
2:34
we have
2:37
the agent force agents that are
2:39
available in your org are exported
2:43
to your
2:45
local VS code. So for example here if I
2:48
go to Salesforce setup
2:56
these are all the agent force agents
2:58
that are available in my Salesforce or
3:01
so we have to export this in our VS
3:04
code.
3:06
So you can make use of this package.xml
3:08
XML even the bot is not needed but still
3:12
if you want you can export the bot so
3:15
that you will have the gen a planner and
3:17
as well as the bot uh whenever we run
3:20
the uh agent force DX commands it makes
3:24
use of gen a planner uh but I wanted to
3:26
export the bot also so you can make use
3:28
of this package doxml and then you have
3:31
to export the gen a planner so here you
3:36
can make use of this package doxml
3:38
And then you can use sfdx retrieve
3:42
source and manufactur from or so that it
3:44
will retrieve the gen a plug-in
3:49
sorry gen a planners.
3:58
It is still exporting the gen a
4:00
planners.
4:04
We have to first create a agent test
4:08
specification file. In order to
4:11
do that, you have to make use of this
4:14
command. So I'm going to make use of
4:17
this command.
4:20
Let this run and complete.
4:25
This will extract
4:28
bot and as well as the gen AI planner
4:30
from my Salesforce arc.
4:40
Okay, let it run. Meanwhile,
4:46
in the terminal, I'm going to
4:52
run this command SF agent generate test
4:56
specification. So, test-en spec. So this
5:00
will create the agent force test
5:02
specification.
5:10
Let me clear this.
5:18
I think I have already exported my gen
5:22
planners. So I'm not going to run this
5:24
uh I'm not going to export it again
5:27
since I have already done it. So let's
5:29
go to the terminal. Let's run this
5:31
command. So this will create agent force
5:34
test specification.
5:38
It is asking me what what am I planning
5:40
to test it. I'm going to test one agent.
5:42
As of now only agent is available. So
5:44
press enter.
5:46
It is asking me which agent force agent
5:49
I have to use. I'm going to say agent
5:52
for service agent. If you wanted to do
5:54
the uh testing for other agents, you can
5:57
use up arrow and down arrow so that you
5:59
will be able to select the agent force
6:02
agent. So here I'm going to use agent
6:04
force service agent.
6:06
So this is my
6:08
agent. Agent for service agent.
6:16
It is asking me the name. So I'm going
6:18
to give the name as a demo testing
6:22
version two or let me give version five.
6:29
So it is asking me
6:31
the test case one. It is asking me for
6:35
the utterance.
6:37
This particular agent force agent is
6:39
tied to
6:43
data library
6:48
which makes use of Salesforce knowledge
6:50
base. So I'm going to make use of
6:54
this as the utterance so that it will
7:00
bring this uh article information.
7:04
So it is asking me next to select the
7:07
expected topic.
7:12
So it should
7:17
take general FAQ
7:21
and then it should fire this answer
7:23
questions with knowledge.
7:26
So I'm going to
7:29
select
7:31
general FAQ.
7:34
and then I'm going to select this
7:36
action.
7:38
Okay, you have to use spacebar to select
7:41
the action. So once that the action is
7:43
selected, you have to press enter. Uh it
7:46
is asking me what is the expected
7:48
outcome. In a natural language, you can
7:50
say it should
7:54
give the steps to
7:58
cancel the
8:00
customer subscription.
8:04
It is asking me whether I have to add
8:06
multiple use cases. I'm going to say no.
8:10
So the specification is created. So this
8:13
is the specification.
8:15
You can check you can verify whether
8:18
everything is uh looking good and then
8:23
so the first uh specification is done.
8:25
It asked me all this information. I have
8:28
entered all this information.
8:30
If you wanted to customize, you can
8:32
customize. For example, if you wanted to
8:34
use context variable in your uh um
8:37
generated uh YAML file, you can
8:40
definitely make use of the context
8:42
variable also. The next step is we have
8:46
to create the agent test. For that you
8:49
can run this command so that you can see
8:53
how the XML file that will be generated
8:56
so that it will create the metadata for
8:58
agent test in your Salesforce arc. Let's
9:01
uh run this command.
9:04
Since I'm using preview, it won't create
9:07
the agent force agent test. it will just
9:10
create the XML file and then it will be
9:12
available in Salesforce VS code and then
9:15
you should be able to verify that.
9:18
So here I'm going to give the same name
9:20
demo testing
9:23
P5
9:27
and I'm going to select this uh
9:31
specification.
9:37
So this is the
9:41
so this is the
9:46
AI evaluation definition that will be
9:48
created in your Salesforce or
9:52
and this is how the XML file will be
9:54
looking like
9:57
after verifying that after verifying
9:59
this
10:01
next instead of using the preview flag
10:04
you can remove that preview flag and
10:06
then You have to run this same command.
10:09
This will create the agent force agent
10:13
test in your Salesforce or if you wanted
10:16
to verify that. Let's see that. So here
10:20
SF agent test create.
10:22
Before that if you go to
10:27
testing center in Salesforce setup you
10:29
should be able to see whether you have
10:32
any agent force agent test. So as of now
10:34
I don't have any.
10:37
So I'm going to create the first test
10:40
agent test. It is asking me the name.
10:42
I'm going to give the name as demo
10:46
testing vi.
10:50
I'm going to make use of this yl file
10:52
which we created.
10:57
Okay. So it created the agent force uh
11:00
test. I don't see any errors.
11:04
If I refresh this, so it created the
11:08
agent force test here.
11:12
The next step is
11:15
we have to run the agent for test in
11:17
your development arc. So the test
11:21
metadata is created
11:24
but we have to run it. So let's see how
11:27
to run it. So this is the command you
11:30
have to make use to
11:34
run the agent force test which you just
11:36
created. In order to
11:40
run it, you have to specify the API name
11:43
of the agent test.
11:45
So this is the API name.
11:53
So let me copy that.
11:56
And you have to paste it here.
12:03
So we don't need a evolution. A
12:07
evaluation. So
12:10
after the API name flag, you have to
12:12
mention the API name of the agent force
12:14
agent test.
12:21
So it successfully submitted the job and
12:24
this is the job ID.
12:30
If you wanted to see the agent force uh
12:32
test results then you have to make use
12:34
of SF agent space test space resume
12:39
double- job id followed by job ID. So
12:43
here this is a placeholder. You have to
12:46
use the job ID which was submitted to
12:49
run the agent force agent test.
12:54
Since we already have this command here,
12:56
you can copy this and then you can run
12:59
this command.
13:02
Okay, it ran. Status is completed. It
13:06
took 25 seconds.
13:09
Outcome and metric pass is 100%. topic
13:12
is uh it looks like it took a different
13:15
uh topic. Okay, instead of SVC copilot
13:20
template general FAQ, it took a
13:24
different Okay. Okay. Maybe I took I
13:26
selected the wrong uh agent force agent
13:30
action. So that's the reason it failed.
13:32
But still it was able to fetch
13:36
the correct knowledge article and then
13:39
it was able to display. Let's look at
13:41
the knowledge article and verify that.
13:45
Okay. Open the account. Click
13:47
submission. Subs subscription details.
13:50
Subscription number. Subscription. Okay.
13:51
Let's verify that. Okay. I can see all
13:54
those information here. when this is
13:58
displayed since we have double asterric
14:01
llm
14:02
added uh or set this as in bold so that
14:06
it will be uh readable and uh easy to
14:10
understand.
14:13
So with the help of VS code
14:16
and Salesforce agent force DX extension
14:20
we were able to successfully
14:22
test agent force agent from VS code.
14:30
Please check the video description. In
14:32
the video description I have shared my
14:34
blog post. From the blog post, you
14:37
should be able to follow all the steps
14:39
whatever we discussed in this video and
14:41
then you should be able to successfully
14:44
start testing your agent force agents
14:46
from VS Code.
14:56
I hope it was helpful.
15:03
Thank you for watching.
#Development Tools
#Internet Software
#Software