Native automation overview

Flutter's integration_test does a good job at providing basic support for integration testing Flutter apps. What it can't do is interaction with the OS your Flutter app is running on. This makes it impossible to test many critical business features:

  • granting runtime permissions
  • signing into the app which uses WebView or 0Auth (like Google) as the login page
  • listing and tapping on notifications
  • exiting the app, coming back, and verifying that state is preserved
  • enabling and disabling features such as Wi-Fi, mobile data, location, or dark mode

Patrol's native automation feature finally solves these problems. Here's a tiny snippet to spice things up:

integration_test/demo_test.dart
void main() {
  patrolTest('demo', (PatrolIntegrationTester $) async {
    await $.pumpWidgetAndSettle(AwesomeApp());
    // prepare network conditions
    await $.native.enableCellular();
    await $.native.disableWifi();

    // toggle system theme
    await $.native.enableDarkMode();

    // handle native location permission request dialog
    await $.native.selectFineLocation();
    await $.native.grantPermissionWhenInUse();

    // tap on the first notification
    await $.native.openNotifications();
    await $.native.tapOnNotificationByIndex(0);
  });
}
Native automation is currently available only on Android and iOS.