# Record a regression test

Source: https://olef.dev/docs/guides/record-a-test

**Outcome:** a saved test folder that reproduces a useful flow and checks its result without a model at replay time.

## Before recording

Use a development app and a known starting state. Choose one behavior: adding a saved item, signing in with a test account, or opening a previously crashing screen. Saving a test normally replays the flow, so it may perform the interaction again.

## Record in the viewer

1. Open the app in a compatible Olef device viewer.
2. Select **Record steps**.
3. Perform the flow. Use **Check** for a visible condition that must hold.
4. Stop recording and inspect the **Steps** list.
5. Choose **Save as test**. Review the replay result and saved folder.
6. Choose **Check it**, or ask your agent to run the test repeatedly.

The default recording starts from the current app state. The fresh-start option can clear app data; use it only when that is the intended setup.

## Ask your agent

```text
Save the flow I just recorded as packing_list. Review the generated
selectors and assertions, tell me about any low-confidence steps, then
run it three times. Keep failures visible rather than weakening the
expected behavior to make it pass.
```

## Run the saved test

Replace the folder name with the path returned when saving:

```bash
olef test run tests/olef/packing_list --repeat 3
```

The folder contains `test.sh`, recording metadata, and screenshots of the steps. The runner produces JSON, JUnit, and HTML reports. A run that passes only after a retry is classified as flaky.

## Record through the CLI

Within an existing [Olef session](https://olef.dev/docs/concepts/sessions), you can name steps and save the session's actions:

```bash
olef record step add-item
# Perform your app-specific actions and checks here.
olef record show
olef record save packing_list
```

Use `record show` to inspect what will be kept before saving. See the [full recording guide](https://olef.dev/docs/concepts/recording) for session setup, parameters, generated checks, and replay behavior.

## Know what the test proves

A recorded check can prove a visible state at a moment in the flow. It does not automatically prove persistence, backend correctness, or behavior on every Android version. Add those actions and checks explicitly, and run the test in the environments you support.

Next: [Run tests in CI](https://olef.dev/docs/guides/ci).
