# Run Android e2e tests in parallel with E2B

> Run Android end-to-end tests in parallel with e2e and E2B. Each worker gets its own Android sandbox, and the machine running e2e needs no local emulator, Android SDK, or adb.

By Kacper Kapuściak. Published 2026-11-20. Canonical URL: https://e2e.com/blog/e2e-and-e2b

[e2e](https://e2e.com/) and [E2B](https://e2e.com/docs/integrations/e2b) let you run Android tests in parallel, with a separate Android sandbox for each worker. Set the worker count, point e2e at your APK, and the integration provisions the sandboxes, installs your app, and deletes them when the run ends.

The E2B team contributed `@e2e-dev/e2b`, the package that connects the two. Here's a run with four Android workers, alongside their sandboxes in the E2B dashboard:

[Video: e2e run with four Android workers, alongside their sandboxes in the E2B dashboard](https://e2e.com/blog/videos/e2e-and-e2b-demo.mp4)

## Isolated Android environments in E2B's agent cloud

Parallel UI tests need a device per worker. Otherwise, one test navigates to checkout while another opens settings, and both fail for reasons that have nothing to do with your app. Provisioning those devices yourself means assigning them to workers, installing the right build, and cleaning up after every run.

With E2B, that's part of the test config. Each worker gets a sandbox from E2B's [`android-16` template](https://docs.e2b.dev/use-cases/android), with Android already booted. e2e installs your APK before the tests start. The machine running e2e needs no local emulator, Android SDK, or `adb`.

## Configure parallel end-to-end testing for Android

In an existing e2e mobile project, install the integration:

```bash
npm install --save-dev e2e @e2e-dev/mobile @e2e-dev/e2b e2b
```

Set `E2B_API_KEY` in the environment that starts e2e (a secret in CI), then configure the Android target in `e2e.config.ts`:

```ts
import type { E2EConfig } from "e2e";
import { mobile } from "@e2e-dev/mobile";
import { e2b } from "@e2e-dev/e2b";

export default {
  targets: [
    {
      name: "android",
      engine: mobile({
        platform: "android",
        device: e2b(),
      }),
      app: {
        appPath: "build/app.apk",
      },
    },
  ],
  workers: 4,
} satisfies E2EConfig;
```

Replace `build/app.apk` with your build and run:

```bash
npx e2e run --target android
```

`device: e2b()` runs Android in E2B. `workers: 4` spreads your test files across four workers, each with its own sandbox. When a worker finishes a file, it picks up the next one. Parallelism is per file, so one long test won't get any faster.

Your existing tests use the same mobile APIs. Tests built on locators and assertions need no model credentials; agent steps need a model configured separately.

## Reduce flaky tests by managing app state and test data

Workers don't share app data, but tests on the same worker can inherit state from earlier ones. Set up the state each test needs explicitly. `app.clearState()` from the [mobile lifecycle APIs](https://e2e.com/docs/mobile) resets the app's local data.

Your backend is still shared. Four sandboxes can log into the same account and edit the same cart, so give independent tests their own accounts or records.

## Automated UI testing for Android in CI/CD

Build the APK in your build job and make it available at `appPath` in the test job. The test job needs your dependencies, `E2B_API_KEY`, and network access to E2B. No KVM or emulator required. For React Native or Expo, use a release APK so the app doesn't depend on Metro. Any backend the app talks to must be reachable from the sandbox.

```bash
npx e2e run --target android --reporter list,junit
```

Keep `.e2e/` as a CI artifact, even when tests fail. It holds the report, test artifacts, and `junit.xml` for your CI's test view. The [CI guide](https://e2e.com/docs/ci) covers uploading them.

## E2B concurrency limits, costs, and timeouts

[E2B's free Hobby plan allows 10 concurrent sandboxes with sessions up to one hour. Pro allows 100, with sessions up to 24 hours](https://e2b.dev/pricing). Hobby has no subscription fee; usage is billed separately, with an initial credit. Each worker uses one sandbox, so leave room for other sandboxes and overlapping CI jobs.

E2B bills sandboxes while they run, and the integration keeps them until the run ends, idle or not. One long file plus a few short ones can leave paid sandboxes waiting. Start with a few workers, compare runtime and usage on your suite, and scale up when the faster feedback is worth it.

If the runner dies before cleanup, E2B deletes the sandboxes when their lifetime expires: one hour by default, including setup. For longer runs, raise `timeoutMs` in `e2b()` within your plan's session limit. E2B enforces it even if tests are still running.

## Give E2B a try

Clone E2B's example and run the Android tests. All they need is an E2B API key:

```bash
cd e2b-cookbook/examples/e2e-android-web-tests-js
npm install
cp .env.example .env     # add E2B_API_KEY
npm run download-apk
npm start
```

Add `ANTHROPIC_API_KEY` to `.env` to run the agent tests too, and run `npm run build-template` once if you want the Chromium tests.

- E2B's e2e example: [github.com/e2b-dev/e2b-cookbook](https://github.com/e2b-dev/e2b-cookbook)
- e2e on E2B: [e2e.com/docs/integrations/e2b](https://e2e.com/docs/integrations/e2b)
- Android on E2B: [e2b.dev/docs/use-cases/android](https://e2b.dev/docs/use-cases/android)

If this saved you one more emulator install, a [star on GitHub](https://github.com/e2e-inc/e2e) helps more people find e2e.
