> ## Documentation Index
> Fetch the complete documentation index at: https://www.minitap.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Run your own Maestro and Espresso tests

> Send your Maestro flows or Espresso test APK to Minitap, let each one run on its own device, and read every result in Script runs.

Your team's Maestro flows and Espresso tests can run on Minitap devices as they are. You upload the app build, send your tests with the CLI or from GitHub Actions, and Minitap runs each Maestro flow, or each Espresso test class, on its own device, records it, and waits for the verdict. The results show up in **Script runs**, next to your [Appium tests](https://www.minitap.ai/docs/minitest/runs/script-runs.md) and Mini's runs.

> [!NOTE]
>
> **Beta.** Maestro and Espresso jobs are being tried with a few teams first. Maestro runs on Android emulators and iPhone simulators. Espresso runs on Android. Ask the Minitap team to turn them on for your workspace.

## What you send

| Framework | Tests | App build |
| - | - | - |
| Maestro | Your flows folder, or a zip of it | An Android `.apk` that runs on an emulator, or an iOS simulator build (an `.app` zipped as `.app.zip`; a device `.ipa` can't run) |
| Espresso | The test APK Gradle builds with `assembleDebugAndroidTest` | The app APK of the same build (`assembleDebug`) |

In a Maestro folder, `config.yaml` and the flows whose names start with `_` stay available to the others (for `runFlow`) and don't run on their own. Each flow starts on a fresh device, so it never sees what another flow left behind. On iPhone simulators `clearState` has no effect, which that fresh start makes unnecessary. A bundle can be up to 50 MB.

## Set up

Open **Settings → Test frameworks** and choose **Set up** on Maestro or Espresso. The setup walks you through three steps:

1. **An API key.** The CLI signs in with a workspace [API key](https://www.minitap.ai/docs/minitest/workspace/api-keys.md). Keep it in your CI's secret store as `MINITEST_API_KEY`.
2. **A first run from your terminal**, with the commands below already filled in with your app ID.
3. **The same run in your CI.**

## Run from your terminal

Install the [CLI](https://www.minitap.ai/docs/minitest/reference/cli-commands.md), upload the build, then send the tests:

```bash theme={"theme":{"light":"github-light","dark":"vesper"}}
uv tool install minitest-cli
export MINITEST_API_KEY=<your key>

BUILD_ID=$(minitest --json --app <app id> build upload app-release.apk | jq -r .id)
minitest --app <app id> script-runs submit --framework maestro \
  --tests ./flows --build-id "$BUILD_ID"
```

For Espresso, use `--framework espresso` and pass the test APK, for example `--tests app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk`.

The command shows progress while the tests run, then prints one line per test with its status and failure reason, the whole stack trace of each failed test, and the link to the run. It exits with:

| Code | Meaning |
| - | - |
| `0` | Every test passed |
| `1` | A test failed |
| `7` | Minitap couldn't run some tests (no device was free in time, the app didn't install…) |

Other options: `--run-name` to name the run, `--commit-sha` and `--branch` to show them on the run, `--model tablet`, `--os-version`, `--timeout` (seconds to wait, one hour by default), and `--no-wait` to return as soon as the run has started.

## Run from GitHub Actions

Store the key as a repository secret named `MINITEST_API_KEY`, then add a job:

```yaml theme={"theme":{"light":"github-light","dark":"vesper"}}
jobs:
  maestro:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      # build your app (and, for Espresso, its test APK) here
      - uses: astral-sh/setup-uv@v6
      - id: build
        env:
          MINITEST_API_KEY: ${{ secrets.MINITEST_API_KEY }}
        run: echo "id=$(uvx --from minitest-cli minitest --json --app <app id> build upload app-release.apk | jq -r .id)" >> "$GITHUB_OUTPUT"
      - uses: minitap-ai/minitest-trigger/script-jobs@v2
        with:
          api-key: ${{ secrets.MINITEST_API_KEY }}
          app-id: <app id>
          framework: maestro
          tests: ./flows
          build-id: ${{ steps.build.outputs.id }}
```

The step waits for the verdict and fails when a test fails. Its job summary lists every test with its failure reason and links the run. The run takes the workflow's name and run number, and the pull request's commit and branch. Set `fail-on-failure: false` to keep the job green and read the verdict from the step's `status` output (`passed`, `failed`, or `error` when no verdict came back), next to `run-url` and `job-id`.

On another CI, run the two terminal commands in a job: the second one exits non-zero when a test fails.

## Read the results

Open **Results → Script runs** and filter on the framework. Each flow or test class has its device, its recording and its tests. A failed Espresso test shows its stack trace, and when the app crashed, the crash from the device log.

The CLI reads the same thing with `minitest script-runs get <run id>`.

## How long we keep them

| What | Kept |
| - | - |
| Runs, tests, recordings and the tests you sent | 90 days |
| Test output (Maestro's step logs and screenshots, device logs) | 30 days |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.