patrol
4.11.0, released 3 weeks ago by leancode.co
Multiplatform E2E UI testing framework for Flutter
What it does
Patrol extends flutter_test and integration_test to allow native UI automation and custom finders. It works on Android, iOS, web, macOS and requires the patrol_cli tool for native setup.
AI-written summary of version 4.11.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- Need to test native platform interactions (e.g., pressing home, opening notifications).
- Require cross‑platform E2E tests for Flutter apps.
- Want concise, readable tests with custom finders.
Skip it when
- Only widget tests are needed, no native interaction.
Strengths
- Native automation across multiple platforms
- Custom finder system for concise tests
- Bundled agent skills for AI‑assisted test writing
- Open‑source and battle‑tested
Weaknesses
- Requires additional patrol_cli installation and native setup
- Learning curve for native automation APIs
- Not suitable for simple widget tests
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 13
Install patrol_cli, follow native setup docs for each platform (Android, iOS, macOS, web).
```dart
import 'package:patrol/patrol.dart';
void main() {
patrolTest('counter state is the same after going to home and going back', ($) async {
await $.pumpWidgetAndSettle(const MyApp());
await $(FloatingActionButton).tap();
expect($(#counterText).text, '1');
await $.platform.mobile.pressHome();
await $.platform.mobile.pressDoubleRecentApps();
expect($(#counterText).text, '1');
await $(FloatingActionButton).tap();
expect($(#counterText).text, '2');
await $.platform.mobile.openNotifications();
await $.platform.mobile.pressBack();
});
}
```Alternatives
Packages that do the same job and could replace patrol.
- flame_test
Classes and helpers for testing applications built with the Flame Engine.
80Compare - test
A full featured library for writing and running Dart tests across platforms.
90Compare - bdd_widget_test
Generate Flutter widget tests from Gherkin feature files
88Compare - bloc_test
A testing library that makes it easy to test blocs and cubits.
82Compare
Works with
Packages commonly used together with patrol: ones it builds on, ones built on it, and its own family.
- vm_servicepatrol depends on itA library to communicate with a service implementing the Dart VM service protocol.
- webpatrol depends on itLightweight bindings for browser APIs via JS interop
- test_apipatrol depends on itThe user facing API for structuring Dart tests and checking expectations.
- shelfpatrol depends on itComposable web server middleware for Dart
- json_annotationpatrol depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- http_multi_serverpatrol depends on itA dart:io HttpServer wrapper that handles requests from multiple servers.
- boolean_selectorpatrol depends on itParses and evaluates simplified Dart-like boolean expression strings.
- equatablepatrol depends on itProvides value‑based equality for Dart objects without manual == and hashCode.