Sub topic 2
Asserting Expected Actions in Agentforce Tests
Assume you know Agentforce topics and actions, have Testing Center enabled, and can read basic YAML. This chapter focuses on validating what an agent does after it selects a topic.
Asserting the Expected Actions
An expected action assertion checks whether the agent invoked the actions required for the request. For example, an order-status request should invoke Get_Order_Status. The action name in the test must match the developer name configured in the agent.
Use the smallest action set that proves the behavior. Adding actions that are not required makes a test fragile. An empty list is useful for requests that should not invoke business actions, such as an out-of-scope question.
testCases:
- utterance: Where is my order 1001?
expectedTopic: Order_Status
expectedActions:
- Get_Order_Status
expectedOutcome: The agent tells the customer the current order status.Writing the Expected Outcome
The expected outcome describes the user-visible result. Make it specific enough to evaluate, but avoid reproducing an exact response unless wording itself matters. State the information the agent must provide and any required safety behavior.
Designing a Useful Test Set
Cover normal requests first, then variations that expose routing and action errors.
- Main paths: use clear requests for every important topic and action.
- Edge cases: vary identifiers, missing details, ambiguous wording, and unusual values.
- Out-of-scope requests: confirm that the agent declines or redirects without invoking unrelated actions.
- Negative cases: verify that an action is not called when the request lacks required information.
A useful test set checks both the happy path and the boundaries of the agent's responsibility.
Creating a Test Suite in Testing Center
In Testing Center, create a test definition for the agent. Give the suite a stable name and description. Add test cases with the user's utterance, expected topic, expected actions, and expected outcome. Save the suite, then run it against the target agent. Keep the suite associated with the agent version or environment you intend to validate.
Defining Tests in YAML or CSV
YAML is convenient for source control because each case is readable and can be reviewed with other agent changes. CSV works well for spreadsheet-based authoring, but long outcome text and lists of actions require consistent column conventions.
Keep developer names in the specification and update them when topics or actions are renamed. Treat the file as a regression artifact, not as a transcript of one exact response.
Exercise
What should expectedActions contain for an out-of-scope request?
Show answer
It should be an empty list when the agent must not invoke an action.