Sub topic 11
Running a test suite
This chapter covers how to run a test suite once it exists, in the UI and with Salesforce CLI. It assumes you know what topics and actions are in an Agentforce agent, that the Testing Center is enabled in your org, and that you have a suite saved. If you have no suite yet, create one first using the spec format from the earlier chapters.
What happens when you run a suite
A run sends each test case's utterance to the agent as if a user had typed it. The Testing Center records which topic the agent chose, which actions it called, and what it replied. It then compares those results with the expected topic, expected actions, and expected outcome in each case.
The run is asynchronous. The org starts a job, works through the cases, and stores the results under a job ID. You can leave the page and come back later.
Run from the Testing Center UI
- Open the Testing Center from Setup, or search for it in App Launcher.
- Select your test suite from the list.
- Confirm the agent shown on the suite is the one you intend to test.
- Click Run.
- Watch the status change from queued to in progress to complete.
Each run is saved as its own record. A later run does not overwrite an earlier one, so you can compare results before and after a change.
Run with Salesforce CLI
The CLI is useful when you want to start runs from a terminal or a script. Create the test definition from your spec, then run it:
sf agent test create --spec specs/order-support-tests.yaml --api-name Order_Support_Agent_Tests --target-org my-org
sf agent test run --api-name Order_Support_Agent_Tests --wait 10 --result-format human --target-org my-orgThe --wait 10 flag makes the command wait up to 10 minutes and print results when the run finishes. Without --wait, the command starts the job and returns right away with a job ID. Use that ID later to fetch the results:
sf agent test results --job-id <JOB_ID> --result-format json --target-org my-orgThe --result-format flag accepts human for reading in a terminal and json for scripts.
Before you run
Most failed first runs come from setup, not from the agent. Check these items:
- The agent is active, or in a state that allows testing, in the target org.
- The topic and action names in your expectations match the developer names in the agent. A label such as "Order Status" will not match
Order_Status. - The actions the agent calls work in this org. Flows and Apex classes they depend on must be deployed and active.
- You are targeting the right org. Check
--target-orgbefore each run.
Common errors
| Symptom | Likely cause |
|---|---|
| Run never leaves queued | Org is busy, or the agent is not available for testing |
| Every case fails on topic | Expected topic names use labels, not developer names |
| CLI returns without results | You omitted `--wait`, so it printed a job ID only |
| Command says the test is not found | The suite was never created in this org, or the API name is misspelled |
Exercise
You run sf agent test run --api-name Order_Support_Agent_Tests --target-org my-org and the command returns a job ID without any pass or fail output. What happened, and how do you get the results?
Show answer
Without --wait, the command only starts the job and returns its ID. Get the results by running sf agent test results --job-id <JOB_ID> --result-format human --target-org my-org, or rerun the test with --wait set to a number of minutes.