Sub topic 3
What the Testing Center does
This chapter describes what the Testing Center is, what it checks, and where it fits in your workflow. It assumes you know what an Agentforce agent, a topic, and an action are. You also need access to an org with Agentforce and the Testing Center enabled. Later chapters cover writing test cases, building suites, and reading results in detail.
The problem it solves
An Agentforce agent is driven by a large language model (LLM). A user types a free-form request, the agent picks a topic, and the topic's instructions guide it to call actions and write a reply. Changing an instruction, a topic description, or an action can change how the agent routes requests. You can't read the agent's configuration and know how it will behave. You have to run it.
Testing by hand in the agent builder works for a first check. It stops working once you have more than a handful of scenarios. You forget to retry old cases, and you can't compare one version against another. The Testing Center replaces that manual loop with a stored, repeatable batch run.
What the Testing Center is
The Testing Center is the Agentforce tool for running a saved set of test cases against an agent and reporting what happened. It does three jobs:
- Stores test cases. A group of cases is a test suite, kept in your org as a test definition.
- Runs them in bulk. Each case sends one utterance (the user's message) to the agent and records the agent's behavior.
- Compares behavior to expectations. For each case it checks the result against what you said should happen, and it reports a result per case.
The test case you write has four parts: an utterance, an expected topic, expected actions, and an expected outcome. The [next chapter](#) covers each part. This chapter only needs the idea that you state your expectation and the Testing Center checks it.
What it evaluates
The Testing Center looks at three things the agent did in response to an utterance.
| Check | Question it answers | How it is judged |
|---|---|---|
| Topic | Did the agent route the request to the right topic? | Compared with the expected topic name |
| Actions | Did the agent call the actions you expected? | Compared with the list of expected actions |
| Outcome | Did the final response do what you described? | Judged against your plain-language description |
The topic and action checks are comparisons of names, so they are close to exact. The outcome check is different. Your expected outcome is a sentence such as "The agent tells the customer the current status of the order." The agent's real reply will never match that sentence word for word, so the Testing Center uses a model to judge whether the reply satisfies the description. This is why outcome results can be less stable than topic and action results. You will see how to handle that in the chapter on nondeterminism.
How a run works
When you start a run, the Testing Center works through the suite one case at a time:
- It sends the utterance to the agent as if a user had typed it.
- The agent reasons, selects a topic, and runs any actions it decides on.
- The Testing Center records which topic was chosen, which actions were called, and what the agent replied.
- It compares those records with the expected topic, expected actions, and expected outcome.
- It stores a result for each case and a summary for the run.
Runs are asynchronous. Starting a run creates a job, and the results appear when the job finishes. Large suites can take minutes, which is why the CLI has a --wait option and a separate command for fetching results by job ID.
What it does not do
Knowing the limits helps you decide what else you need.
- It does not test one component alone. It tests the agent end to end. If a Flow or Apex action is broken, the Testing Center shows that the case failed, but you need separate tests for that code.
- It does not guarantee identical output every run. The agent is nondeterministic. The same utterance can produce a slightly different reply on the next run.
- It does not write your intent for you. It can only check what you tell it to expect. A suite with weak expectations passes while the agent is wrong.
- It is not a load test. It checks correctness of behavior, not how the agent performs under traffic.
Actions run for real
The Testing Center runs the agent, and the agent runs its actions. If an action creates a record, sends an email, or updates a case, a test can do that too. Treat this as a design constraint:
- Run suites in a sandbox or a scratch org when actions write data.
- Use test records, such as a known order number, as the data in your utterances.
- Check which actions have side effects before you add them to a suite you plan to run often.
Two ways to work
You can use the Testing Center in two ways, and they work on the same test definitions.
- In the UI. You create a suite, add cases, run it, and read the results in Setup. This is good for exploring and for building your first suite.
- With Salesforce CLI. You describe the suite in a YAML spec, create it in the org, and run it from a terminal or a pipeline. This is good for version control and automation.
A minimal spec shows the shape of a suite. The topic and action names must match the developer names in your own agent.
name: Order_Support_Agent_Tests
description: Minimal suite with one case
subjectType: AGENT
subjectName: Order_Support_Agent
testCases:
- utterance: Where is my order 1001?
expectedTopic: Order_Status
expectedActions:
- Get_Order_Status
expectedOutcome: The agent tells the customer the current status of the order.The four CLI commands you will use most are listed here. Each is covered in the CLI chapter.
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-org
sf agent test list --target-org my-org
sf agent test results --job-id <JOB_ID> --result-format json --target-org my-orgThe create command registers the definition in the org. The run command executes it and waits up to 10 minutes. The list command shows the definitions that exist. The results command fetches a past run by its job ID.
What a result tells you
For each case you get a pass or fail on each of the three checks, not only one verdict for the whole case. That detail matters for debugging. A case can pass the topic check, fail the action check, and pass the outcome check. Each pattern points to a different cause:
- Wrong topic: the topic descriptions or the utterance are the likely cause.
- Right topic, wrong or missing action: the action's description, inputs, or the topic's instructions need work.
- Right topic and actions, wrong outcome: the reply wording or the expectation itself needs work.
The diagnosis chapter walks through these patterns. For now, remember that the Testing Center reports where the behavior diverged, not only that it did.
Where it fits in your workflow
The Testing Center is most useful at three points:
- While building. Write a few cases before you tune instructions, then run them after each change.
- Before activation. Run the whole suite as a gate before you activate a new agent version.
- After changes. When topics, actions, or instructions change, rerun the suite to catch regressions, which are behaviors that used to work and no longer do.
Exercise
An agent's test case passes the topic check and the action check but fails the outcome check. Name one reason this can happen that does not mean the agent behaved badly, and one thing you would do about it.
Show answer
The outcome check is judged by a model against your plain-language description, so a vague or overly specific expected outcome can cause a failure even when the reply is acceptable. Read the actual reply, and if it is acceptable, rewrite the expected outcome to describe the required result more precisely. If the reply is wrong, adjust the agent's instructions instead.
Exercise
Why should you run a suite that includes a cancel-order action in a sandbox instead of production?
Show answer
The Testing Center runs the agent's real actions, so a test utterance can change real data. A sandbox with test records keeps those side effects away from production.