---
title: build
---

### Synopsis

Build app binaries for integration testing.

```
patrol build android
patrol build ios
```

To see all available options and flags, run `patrol build android --help` or
`patrol build ios --help`.

<Info>
  For `patrol build` to work, you must complete [native setup].
</Info>

### Description

`patrol build` is useful if you want to run test on CI, for example on Firebase
Test Lab. It works the same as `patrol test`, except that it does not run tests.

`patrol build` builds apps in debug mode by default.

<Info>
  To run tests on a physical iOS device on a device farm, the apps have to be
  built in release mode. To do so, pass the `--release` flag.
</Info>

### Examples

**To build a single test for Android in debug mode**

```
patrol build android --target patrol_test/example_test.dart
```

or alternatively (but redundantly):

```
patrol build android --target patrol_test/example_test.dart --debug
```

**To build all tests for Android in debug mode**

```
patrol build android
```

**To build a single test for iOS device in release mode**

```
patrol build ios --target patrol_test/example_test.dart --release
```

**To build a single test for iOS simulator in debug mode**

```
patrol build ios --target patrol_test/example_test.dart --debug
```

**To build with custom build name and number**

```
patrol build android --build-name=1.2.3 --build-number=123
patrol build ios --build-name=1.2.3 --build-number=123  --release
```

**To build with full isolation between tests**

```
patrol build ios --full-isolation
```

The `--full-isolation` flag enables full isolation between test runs on iOS Simulator.

### Build-time test discovery

With the experimental `--emit-test-manifest` flag (or `patrol.emit_test_manifest:
true` in `pubspec.yaml`), `patrol build` discovers your Dart tests at build time
and generates a static native test method for each one. This makes every test
individually addressable, which enables per-test sharding and
[`patrol test-without-building`](/cli-commands/test-without-building).

```
patrol build android --emit-test-manifest
patrol build ios --emit-test-manifest
```

See [Build-time test discovery][discovery] for setup (including the required iOS
`RunnerUITests.m` change) and trade-offs.

[discovery]: /documentation/ci/build-time-test-discovery

### Under the hood

The `patrol build` command walks through hierarchy of the `patrol_test`
directory and finds all files that end with `_test.dart`, and then creates an
additional "test bundle" file that references all the tests it found. Thanks to
this, all tests are built into a single app binary - only a single build is
required, which greatly reduces time spent on building. Then, it runs a new app
process for every test, improving isolation between tests and enabling sharding.

We call this feature **advanced test bundling**. It provides deep and seamless
integration with existing Android and iOS testing tools. It also fixes some
long-standing Flutter issues:

- [#115751](https://github.com/flutter/flutter/issues/115751)
- [#101296](https://github.com/flutter/flutter/issues/101296)
- [#117386](https://github.com/flutter/flutter/issues/117386)

We think that **this is huge** (even though it may not look like it at first
glance). To learn more, read [the in-depth technical article][patrol_v2_article]
explaining the nuts and bolts.

[patrol_v2_article]: https://leancode.co/blog/patrol-2-0-improved-flutter-ui-testing
[native setup]: /documentation
