# agent test results

Get the results of a completed agent test run.

## Description for agent test results

This command requires a job ID, which the original "agent test run" command displays when it completes. You can also use the --use-most-recent flag to see results for the most recently run agent test.

By default, this command outputs test results in human-readable tables for each test case. The tables show whether the test case passed, the expected and actual values, the test score, how long the test took, and more. Use the --result-format to display the test results in JSON or Junit format. Use the --output-dir flag to write the results to a file rather than to the terminal.

## Flags

| Flag Name (Long)  | Flag Name (Short) | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ----------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--api-version`   | N/A               | **Type:** Value<br><br>Override the api version used for api requests made by this command                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `--flags-dir`     | N/A               | **Type:** Value<br><br>Import flag values from a directory.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `--job-id`        | `-i`              | **Type:** Value<br>**Required**<br><br>Job ID of the completed agent test run.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `--json`          | N/A               | **Type:** Boolean<br><br>Format output as json.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `--output-dir`    | `-d`              | **Type:** Value<br><br>Directory to write the agent test results into.<br><br>If the agent test run completes, write the results to the specified directory. If the test is still running, the test results aren't written.                                                                                                                                                                                                                                                                                                                                                                              |
| `--result-format` | N/A               | **Type:** Value<br>**Valid Values:** `json`, `human`, `junit`, `tap`<br>**Default value:** `human`<br><br>Format of the agent test run results.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `--target-org`    | `-o`              | **Type:** Value<br>**Required**<br><br>Username or alias of the target org. Not required if the `target-org` configuration variable is already set.                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `--test-runner`   | 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.                                                                                                                            |
| `--verbose`       | N/A               | **Type:** Boolean<br><br>Show generated data in the test results output.<br><br>When enabled, includes detailed generated data (such as invoked actions) in the human-readable test results output. This is useful for debugging test failures and understanding what actions were actually invoked during the test run.<br><br>The generated data is in JSON format and includes the Apex classes or Flows that were invoked, the Salesforce objects that were touched, and so on. Use the JSON structure of this information to build the test case JSONPath expression when using custom evaluations. |

## Examples for agent test results

Get the results of an agent test run in your default org using its job ID:

```shell
sf agent test results --job-id 4KBfake0000003F4AQ
```

Get the results of the most recently run agent test in an org with alias "my-org":

```shell
sf agent test results --use-most-recent --target-org my-org
```

Get the results of the most recently run agent test in your default org, and write the JSON-formatted results into a directory called "test-results":

```shell
sf agent test results --use-most-recent --output-dir ./test-results --result-format json
```
