---
schema_version: "1"
id: 2673d20552042461bf6066b16232668ab8ce4e60058ad642c523e73a7779441e
title: flow run test
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/sfclireference/guides/flow/cli_reference_flow_run_test.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_flow_run_test.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 03b1091f91013f9c4d8a31316df8d6178076e897132aeb825c5d0e1b46ba5575
products:
  - Salesforce CLI Command Reference
  - salesforcedx
---
<!-- prettier-ignore-start -->

# flow run test

Invoke flow tests in an org.

## Description for flow run test

Specify which tests to run by using the --class-names flag followed by the names of the flows you want to test. For example, if you save a flow with the name Flow1, then use: --class-names Flow1.

To see code coverage results, use the --code-coverage flag with --result-format. The output displays a high-level summary of the test run and the code coverage values for classes in your org. If you specify human-readable result format, use the --detailed-coverage flag to see detailed coverage results for each test method run.

By default, "flow run test" runs asynchronously and immediately returns a test run ID. If you use the -–synchronous flag, you can use the --wait flag to specify the number of minutes to wait; if the tests finish in that timeframe, the command displays the results. If the tests haven't finished by the end of the wait time, the command displays a test run ID. Use the "flow get test --test-run-id" command to get the results.

To run both Flow and Apex tests together, run the "sf logic run test" CLI command, which has similar flags as this command, but expands the --tests flag to also include Apex tests.

You must have the "View All Data" org system permission to use this command. The permission is disabled by default and can be enabled only by a system administrator.

## Flags

| Flag Name (Long) | Flag Name (Short) | Description |
|------------------|-------------------|-------------|
| <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;class&#8209;names</code> | <code>&#8209;n</code> | **Type:** Value<br><br>Flow names that contain flow tests to run.<br><br>Default is all flow tests. If you select --class-names, you can't specify --tests. |
| <code>&#8209;&#8209;code&#8209;coverage</code> | <code>&#8209;c</code> | **Type:** Boolean<br><br>Retrieve code coverage results. |
| <code>&#8209;&#8209;concise</code> | N/A | **Type:** Boolean<br><br>Display only failed test results; works with human-readable output only. |
| <code>&#8209;&#8209;flags&#8209;dir</code> | N/A | **Type:** Value<br><br>Import flag values from a directory. |
| <code>&#8209;&#8209;json</code> | N/A | **Type:** Boolean<br><br>Format output as json. |
| <code>&#8209;&#8209;output&#8209;dir</code> | <code>&#8209;d</code> | **Type:** Value<br><br>Directory in which to store test result files. |
| <code>&#8209;&#8209;result&#8209;format</code> | <code>&#8209;r</code> | **Type:** Value<br>**Valid Values:** `human`, `tap`, `junit`, `json`<br>**Default value:** `human`<br><br>Format of the test results. |
| <code>&#8209;&#8209;suite&#8209;names</code> | <code>&#8209;s</code> | **Type:** Value<br><br>Not available for flow tests.<br><br>Not available for flow tests. |
| <code>&#8209;&#8209;synchronous</code> | <code>&#8209;y</code> | **Type:** Boolean<br><br>Run flow tests for one flow synchronously; if not specified, tests are run asynchronously. |
| <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;level</code> | <code>&#8209;l</code> | **Type:** Value<br>**Valid Values:** `RunLocalTests`, `RunAllTestsInOrg`, `RunSpecifiedTests`<br><br>Level of tests to run; default is RunLocalTests.<br><br>Here's what the levels mean:<br><br><ul><li>RunLocalTests — All tests in your org are run, except the ones that originate from installed managed and unlocked packages.</li><li>RunAllTestsInOrg — All tests are run. The tests include all tests in your org, including tests of managed packages.</li><li>RunSpecifiedTests - Only the tests that you specify with the --tests flag are run.</li></ul> |
| <code>&#8209;&#8209;tests</code> | <code>&#8209;t</code> | **Type:** Value<br><br>Flow test names to run.<br><br>Default is all flow tests. If you specify --tests, you can't specify --class-names. |

## Examples for flow run test

Run all local tests in your default org:

```shell
sf flow run test --test-level RunLocalTests
```

Run all the Flow1 and Flow2 flow tests in the org with alias “scratchOrg”:

```shell
sf flow run test --target-org scratchOrg --class-names Flow1 --class-names Flow2
```

Run specific Flow1 and Flow2 flow tests in your default org:

```shell
sf flow run test --tests Flow1.Test1 --tests Flow2.Test2 --test-level RunSpecifiedTests
```

Run all tests synchronously in your default org; the command waits to display the test results until all tests finish:

```shell
sf flow run test –synchronous
```

Run all local tests in the org with the username “me@my.org”; save the output to the specified directory:

```shell
sf flow run test --test-level RunLocalTests --output-dir /Users/susan/temp/cliOutput --target-org me@my.org
```
<!-- prettier-ignore-end -->
