---
schema_version: "1"
id: ec5d834f87574a928f40becfe75ed16f73ea2b1147c5746dab1a16be31c07007
title: agent test create
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfclireference/guides/agent/cli_reference_agent_test_create.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_agent_test_create.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a017795370d3ac6391a186e2cceef56e871e08f472ee7967cd7a557d7654dd01
products:
  - Salesforce CLI Command Reference
  - salesforcedx
---
<!-- prettier-ignore-start -->

# agent test create

Create an agent test in your org using a local test spec YAML file.

## Description for agent test create

To run this command, you must have an agent test spec file, which is a YAML file that lists the test cases for testing a specific agent. Use the "agent generate test-spec" CLI command to generate a test spec file. Then specify the file to this command with the --spec flag, or run this command with no flags to be prompted.

When this command completes, your org contains the new agent test, which you can view and edit using the Testing Center UI (legacy) or Agentforce Studio (NGT). This command also retrieves the metadata component associated with the new test to your local Salesforce DX project and displays its filename. By default, the legacy AiEvaluationDefinition is created; use --test-runner agentforce-studio to author an AiTestingDefinition (NGT) instead.

After you've created the test in the org, use the "agent test run" command to run it.

## Flags

| Flag Name (Long) | Flag Name (Short) | Description |
|------------------|-------------------|-------------|
| <code>&#8209;&#8209;api&#8209;name</code> | N/A | **Type:** Value<br><br>API name of the new test; the API name must not exist in the org. |
| <code>&#8209;&#8209;api&#8209;version</code> | N/A | **Type:** Value<br><br>Override the api version used for api requests made by this command |
| <code>&#8209;&#8209;flags&#8209;dir</code> | N/A | **Type:** Value<br><br>Import flag values from a directory. |
| <code>&#8209;&#8209;force&#8209;overwrite</code> | N/A | **Type:** Boolean<br><br>Don't prompt for confirmation when overwriting an existing test (based on API name) in your org. |
| <code>&#8209;&#8209;json</code> | N/A | **Type:** Boolean<br><br>Format output as json. |
| <code>&#8209;&#8209;preview</code> | N/A | **Type:** Boolean<br><br>Preview the test metadata file without deploying to your org. |
| <code>&#8209;&#8209;spec</code> | N/A | **Type:** Value<br><br>Path to the test spec YAML file. |
| <code>&#8209;&#8209;target&#8209;org</code> | <code>&#8209;o</code> | **Type:** Value<br>**Required**<br><br>Username or alias of the target org. Not required if the `target-org` configuration variable is already set. |
| <code>&#8209;&#8209;test&#8209;runner</code> | N/A | **Type:** Value<br>**Valid Values:** `agentforce-studio`, `testing-center`<br><br>Explicitly specify which test runner to use (agentforce-studio or testing-center).<br><br>By default, the command automatically detects which test runner to use based on the test definition metadata type in your org. Use this flag to explicitly specify the runner type. 'agentforce-studio' uses AiTestingDefinition metadata. 'testing-center' uses AiEvaluationDefinition metadata. |

## Examples for agent test create

Create an agent test interactively and be prompted for the test spec and API name of the test in the org; use the default org:

```shell
sf agent test create
```

Create an agent test and use flags to specify all required information; if a test with same API name already exists in the org, overwrite it without confirmation. Use the org with alias "my-org":

```shell
sf agent test create --spec specs/Resort_Manager-testSpec.yaml --api-name Resort_Manager_Test --force-overwrite --target-org my-org
```

Preview what the agent test metadata (AiEvaluationDefinition) looks like without deploying it to your default org:

```shell
sf agent test create --spec specs/Resort_Manager-testSpec.yaml --api-name Resort_Manager_Test --preview
```

Author an Agentforce Studio (NGT) test from an NGT-shaped YAML; writes an AiTestingDefinition metadata file:

```shell
sf agent test create --spec specs/ReturnsCheckout.ngt.yaml --api-name Returns_Checkout --test-runner agentforce-studio --target-org my-org
```
<!-- prettier-ignore-end -->
