patrol test command is the primary way to run your integration tests. It builds your app, installs it on the target device, and executes tests using native test runners.
Synopsis
Description
This command performs the following steps:- Bundles tests - Creates a single test bundle from all test files
- Builds apps - Compiles both the app under test and instrumentation app
- Installs apps - Deploys to the selected device or simulator
- Runs tests - Executes tests natively via Gradle (Android) or xcodebuild (iOS)
- Reports results - Displays test output in native format
patrol test runs all test files ending with _test.dart in the patrol_test directory.
Basic Usage
Run all tests
Run a specific test file
Run multiple test files
There’s no difference between
--target and --targets. Use whichever feels more natural.Test Selection
Target Options
Specify integration test file(s) to run. Can be used multiple times.
Exclude specific test files from execution.
Tags
Use tags to selectively run tests based on metadata:Boolean expression to select tests by tags.Supports operators:
&& (AND), || (OR), ! (NOT), and parentheses for grouping.Exclude tests with specific tags.
For comprehensive information about tag syntax and advanced usage, see the Patrol tags documentation.
Device Selection
Specify which device to run tests on. Accepts device ID, emulator name, or “all”.
Build Configuration
Build Mode
Build in debug mode (default).
Build in profile mode for performance testing.
Build in release mode. Required for physical iOS devices on device farms.
Flavors
Build a specific flavor of your app.
Flavors are not supported on the web platform.
Build Versioning
Set the version name (e.g., “1.2.3”).
Set the version code (e.g., “123”).
Dart Defines
Pass environment variables to your app. Can be used multiple times.
Load environment variables from a file.
Platform-Specific Options
Android
Override the Android package name.
iOS
Override the iOS bundle identifier.
Specify iOS version for simulators.
Uninstall the app between test runs on iOS Simulator for full isolation.
Clear permissions before running each test on iOS.
Coverage
Collect code coverage during test execution.The LCOV report will be saved to
coverage/patrol_lcov.info.Exclude files from coverage using glob patterns.
Specify package name regex for coverage (defaults to current package).
Test Execution Options
Uninstall the app before and after testing.
Display Flutter framework logs during test execution.
Hide individual test steps from output.
Clear test steps after each test completes.
Display label overlay on the app during testing.
Web Platform
Patrol supports running tests on Flutter web using Playwright:- Tests execute in Chromium browser via Playwright
- Test results are generated in
test-results/ - Configure Playwright using web-specific flags
Web-Specific Options
Playwright reporters to use (JSON array).
Number of times to retry failed tests.
Maximum number of parallel workers.
Test timeout in milliseconds.
Run browser in headless mode.
Video recording mode:
off, on, retain-on-failure, on-first-retry.Web tests don’t support
--flavor, --uninstall, --clear-permissions, or --full-isolation flags.Advanced Options
Port for the test instrumentation server.
Port for the app under test server.
Verify dependency compatibility before running tests.
Generate test bundle file.
Disable icon tree shaking during build.
Examples
Output
The command outputs test results in native format:Under the Hood
patrol test essentially calls patrol build and then runs the built app binaries. It leverages:
- Gradle and Android Test Orchestrator on Android
- xcodebuild and XCTest on iOS/macOS
- Playwright on web
Troubleshooting
Build Failures
If the build fails:- Ensure you’ve completed native setup
- Check that your Flutter and Dart versions are compatible
- Run
patrol doctorto verify your environment - Try cleaning:
flutter clean && flutter pub get
Test Failures
If tests fail unexpectedly:- Use
--show-flutter-logsto see detailed logs - Check device logs with
flutter logs - Verify network connectivity for API calls
- Ensure proper test isolation (use
--full-isolationon iOS)
Port Conflicts
If you see port conflict errors:Related Commands
- patrol develop - Develop tests with Hot Restart
- patrol build - Build test binaries without running
- patrol devices - List available devices