Skip to main content

Time Estimate

Topics

Ask the Community

Use AI to Generate Tests

Learning Objectives

After completing this unit, you’ll be able to:

  • Use AI to generate test cases.
  • Execute batch testing in the Agentforce Testing Center.

Let AI Generate Your Tests

Manually creating a diverse and scalable set of test scenarios is time-consuming and complex. The Agentforce Testing Center has the solution. You can now use AI to effortlessly generate hundreds of synthetic interactions based on the agent’s topics and actions to be used as test cases. This helps ensure that your agents handle various customer interactions accurately.

Then you run those tests automatically in parallel to see what topics and actions the agent chooses. From there, you can iterate by adjusting agent instructions and guardrails as needed—saving time that would have been lost on manually testing many different variations of a conversation. The result is a faster time to testing and a faster time to a more trusted agent that you feel confident deploying.

A good-quality test case dataset has three quality attributes.

  • Volume: A sufficient number of test cases to ensure comprehensive coverage of different scenarios and edge cases.
  • Diversity: A wide range of inputs, contexts, and variations to test the AI agent’s adaptability across real-world use cases.
  • Quality: Well-defined, accurate, and relevant test cases aligned with the AI agent’s objectives.

To complete this unit, you’ll need to use the special Developer Edition org you created in the last unit. When you’re finished following the step-by-step instructions, click Check Challenge to Earn 500 Points at the bottom of the page.

Batch Testing

There are a couple of ways to get to the Agentforce Testing Center. You already used the direct way in the last unit. There’s also a Batch Test button right in Agentforce Builder that takes you right to the Agentforce Testing Center. Let’s give it a go.

Note

Important!

  • Running tests consumes requests and credits. See Considerations for Testing Center.
  • Testing agents can modify CRM data. To avoid issues, be sure to use the Agentforce Testing Center only in your sandbox environment.
  1. From Setup, in the Quick Find box, search for and select Agentforce Agents.
  2. Click Einstein Copilot or Agentforce (Default).
  3. Click Open in Builder.
  4. Click Batch Test. This opens up the Agentforce Testing Center in a new tab with the New Test window open and the Einstein Copilot - v1 or Agentforce (Default) v1 already selected.
  5. For Test Name, enter Generated Test Agentforce v1.
  6. For Description, enter Test cases for Agentforce to verify account summaries and details.
  7. Click Next.
  8. Click Next.
  9. Click Generate Test Cases.
  10. For Number of test cases, leave it at 20.
  11. For Describe the test cases and provide some examples, enter Generate realistic inquiries that customers might ask about their user account, orders, and other general questions about products. This is also where you can define the number of these test cases that are positive and negative to create diversity in your test cases.
  12. For Select the topics for your test cases, leave them all checked. Note that you can select different topics for the different tests you create.
  13. Click Next.

New Test window with settings as described above.

  1. Click Generate Test Cases.

Testing Center Generated Test Agentforce v1 with Creating test cases displayed.

  1. Wait for the test to be generated. You may have to refresh your browser as it may take a bit to generate the tests. Click Run Test Suite. You might have to refresh the page.

Testing Center Generated Test Agentforce v1 with Run Test Suite and Download Test Cases buttons.

  1. Click Refresh to refresh the results.

Test Results showing a Pass for Topic Test Result.

Once the tests are created, you can download them to make sure the agent is doing what you want it to do. You can also fine-tune the agent as needed. In the next unit, you take a closer look at the test results and use Agentforce Builder to troubleshoot a failed test.

Make sure to click Check Challenge to Earn 500 Points before moving on to the next unit.

Resources

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback