Deploy and Run Tests in the Command Line

This topic outlines how to use the Testing API directly in the command line with the Agentforce Vibes Extension and Agentforce DX extensions.

Prerequisites 

See the Testing API workflow diagram for basic overview of how you can use the Testing API.

For guidance on creating a project or authorizing your org in VS Code, see Create Project.

Complete the required setup steps for the Testing API:

  • Create an External Client App.
  • Turn on Agents, and have at least one active Agent. The API name for Agentforce (Default) is Copilot_for_Salesforce.

Deploy Test Case Metadata 

For sample aiEvaluationDefinition XML, see Build Tests in Metadata API.

Note

To deploy the test definition to your org in the CLI, use the project deploy start command. For more information, see Salesforce CLI Command Reference.

sf project deploy start

You can also deploy your test case with the Command Palette using SFDX: Deploy This Source to Org.

Run Tests With Agentforce DX 

You can run tests in the command line with Agentforce DX using the agent test run command. To run tests with Agentforce DX, you'll need the API name of the agent you want to test as well as your development org.

Agentforce DX Run Test Command
sf agent test run --api-name Resort_Manager_Test --target-org my-dev-org

For more information on running tests via the CLI, see Run Agent Tests with Agentforce DX.

View Test Results 

You can call Connect API endpoints via Agentforce DX with the api request rest command.

Get Test Results
sf api request rest services/data/v63.0/einstein/ai-evaluations/runs/4KBSM00000000Xt4AI/results

Replace the runId in the example command to call the Get Test Results endpoint.