# olef test

Source: https://olef.dev/docs/reference/cli/test

Generated from **Olef 3.0.2**. [All commands](https://olef.dev/docs/reference/commands) · [Capabilities and requirements](https://olef.dev/docs/reference/capabilities)

These entries describe available commands, not a sequence to run. Check prerequisites before changing app, device, or cloud state. Global options are listed in the [command catalog](https://olef.dev/docs/reference/commands#global-options).

## olef test

Run a command that needs the device's single UiAutomation slot (instrumentation tests, `uiautomator dump`, `android layout`): disconnects Olef, runs the given command (stdio inherited), then reconnects (unless `--no-reconnect`). Exits with the command's status

```bash
olef test --help
```

Output: **passthrough_with_json_trailer**.

| Argument | Description |
| --- | --- |
| `--no-reconnect` | Leave Olef disconnected after the command finishes |
| `<command>` | **Required.** The command to run, after `--` |

### olef test run

Run test folders (each with a `test.sh`), or folders of them, one at a time per device. Each run gets its own folder (journal, failure report, report.html); the run writes JUnit XML, report.json and an index report.html, with flake classification when --repeat &gt; 1. Exits non-zero when any repetition of a test still failed after its retries

```bash
olef test run --help
```

Output: **json**.

| Argument | Description |
| --- | --- |
| `<paths>` | Test folders (with `test.sh`), folders of test folders, or scripts. Default: `tests/olef` |
| `--repeat <REPEAT>` | Run every test this many times and classify each test and step as stable_pass, stable_fail or flaky Default: `1`. |
| `--retries <RETRIES>` | Rerun a failed test up to this many times; a pass after a retry is reported as flaky (JUnit `<flakyFailure>`), never as a plain pass Default: `0`. |
| `--env <KEY=VALUE>` | Set a script parameter (environment variable), e.g. `--env CALLSIGN=Grace` |
| `--params <GLOB>` | Run each test once per data set: `.env` files matching this glob (relative to the test folder, else the working directory), each a list of KEY=VALUE lines |
| `--capture <CAPTURE>` | Evidence per step: `failures` (default under test run), `steps` (a screenshot after every step, ~0.1 s each) or `off` Values: `steps`, `failures`, `off`. |
| `--shard <I/N>` | Run only shard I of N (1-based) of the sorted test list, e.g. `2/4` |
| `--junit-out <FILE>` | Write JUnit XML here (default: `<artifacts-dir>/junit.xml`) |
| `--artifacts-dir <DIR>` | Where run folders and reports go (default: `.olef/test-runs/<timestamp>/`) |
| `--fail-fast` | Stop after the first test that fails (after its retries) |
| `--timeout-ms <MS>` | Stop a script (and every command it started) that runs longer than this; the attempt fails with `test_timeout` Default: `900000`. |
| `--json` | Accepted for compatibility; output is always JSON. |

Examples from the CLI (replace sample packages, selectors, and paths with your own):

```bash
olef test run tests/olef --repeat 10 --junit-out build/junit.xml
olef test run tests/olef/mission_recovery --retries 1 --env CALLSIGN=Grace
```

### olef test report

Build JUnit XML and a flake report from run folders left by direct `bash test.sh` runs or by `test run`

```bash
olef test report --help
```

Output: **json**.

| Argument | Description |
| --- | --- |
| `<runs>` | **Required.** Run folders, or folders holding them (a `test run` artifacts folder) |
| `--junit-out <FILE>` | Write JUnit XML here |
| `--json` | Include the whole report (every run and step) in the output |
| `--baseline <RUN>` | Flag steps that got slower than in this earlier run folder (or test run artifacts folder) |

Examples from the CLI (replace sample packages, selectors, and paths with your own):

```bash
olef test report .olef/sessions --junit-out junit.xml
```

### olef test lint

Check scripts for coordinates, text-only selectors, missing checks, sleeps, missing `set -euo pipefail` or trap, unquoted parameters, secrets in literal text, Bash 4 features and custom code. Exits non-zero on errors

```bash
olef test lint --help
```

Output: **json**.

| Argument | Description |
| --- | --- |
| `<paths>` | Test folders, folders of test folders, or scripts. Default: `tests/olef` |
| `--json` | Accepted for compatibility; output is always JSON. |

Examples from the CLI (replace sample packages, selectors, and paths with your own):

```bash
olef test lint tests/olef
```

### olef test show

Print a script's parameters, steps and commands as read back (argv lists for other tools), without running it

```bash
olef test show --help
```

Output: **json**.

| Argument | Description |
| --- | --- |
| `<script>` | **Required.** The script (`test.sh`) or its test folder |
| `--json` | Print JSON (the default output is plain text) |

Examples from the CLI (replace sample packages, selectors, and paths with your own):

```bash
olef test show tests/olef/mission_recovery/test.sh --json
```

### olef test heal

Propose a one-line patch for a failed run (a selector from the failure's closest candidates, or a changed expectation to confirm). Never edits the script

```bash
olef test heal --help
```

Output: **json**.

| Argument | Description |
| --- | --- |
| `<test>` | **Required.** The test folder (with `test.sh`) or the script |
| `--from <RUN_FOLDER>` | **Required.** The failed run folder to heal from |
| `--out <FILE>` / `-o` | Write the patch here (default: `<run-folder>/heal.patch`) |
| `--json` | Accepted for compatibility; output is always JSON. |

Examples from the CLI (replace sample packages, selectors, and paths with your own):

```bash
olef test heal tests/olef/mission_recovery --from .olef/test-runs/run-1/mission_recovery/r001-a1
```
