> For the complete documentation index, see [llms.txt](https://docs.cloudbeat.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudbeat.io/references/cloudbeat-cli/running-tests.md).

# Running Tests

Start test cases and suites in CloudBeat from the command line and get JUnit XML reports

The commands on this page are typically used from a CI/CD pipeline; see [CI/CD Pipeline](/features/integrations/ci-cd-tools.md) for the pipeline setup. They expect the API key to be [available](/references/cloudbeat-cli.md#authentication) as an option, an environment variable or a stored login.

## `start`

Executes the specified test case or suite, waits for the run to finish, and produces an XML report in JUnit format. The exit code is 0 when the test execution succeeds and 1 otherwise.

```bash
cloudbeat-cli start <testType> <testId> [options]
```

**Arguments**:

* `testType` - either `case` or `suite`.
* `testId` - the id of the test case or suite. With `--project`, its name.

**Options**:

* `--project <projectName>` - project name. If specified, `<testId>` is the case or suite name instead of an id.
* `--tags <tags>` - comma separated tags; only tests marked with them are executed. Works with suites only, and overrides the tags selected in the CloudBeat UI.
* `-e, --env <environmentName>` - the environment to use for the execution. It must already exist in CloudBeat for the project.
* `--envId <environmentId>` - the same, by environment id.
* `-a, --attr <attributes>` - comma separated name-value pairs passed to the test scripts, e.g. `foo=bar,baz=qux`. Available to the tests as the `attributes` property.
* `--release <releaseName>` - name of the release or version to associate with the test result.
* `--build <buildName>` - name of the build to associate with the test result. Requires `--release`.
* `--format <junit>` - report format. Currently only `junit` is supported.
* `--suffix <time|id>` - suffix for the report file name.
* `--folder <folder>` - directory where the report is saved. Default: the current working directory.
* `--silent` - do not print test progress details.

**Examples**:

Execute a test case by its id, using a named environment and passing attributes to the test:

```bash
cloudbeat-cli start case 70224 --env MyEnvironment --attr foo=bar,baz=qux
```

Execute a test case by its name (the project name is required as well):

```bash
cloudbeat-cli start case "My Case" --project "My Project"
```

Execute only the tests of a suite which are marked with the given tags:

```bash
cloudbeat-cli start suite 34984 --tags smoke,checkout
```

Pass the API key explicitly instead of using `CB_API_KEY` or a stored login:

```bash
cloudbeat-cli --apiKey AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE --apiBaseUrl https://api.cloudbeat.io start suite 34984
```

## `run-status`

Retrieves the status of a run which is currently executing:

```bash
cloudbeat-cli run-status <runId>
```

## `run-result`

Retrieves the result data of a finished run:

```bash
cloudbeat-cli run-result <runId>
```
