patrol 1.1.4 copy "patrol: ^1.1.4" to clipboard
patrol: ^1.1.4 copied to clipboard

Powerful Flutter-native UI testing framework overcoming limitations of existing Flutter testing tools. Ready for action!

patrol #

patrol on pub.dev codestyle

patrol package builds on top of flutter_test and integration_test to make it easy to control the native UI from Dart test code.

It also provides a new custom finder system to make Flutter widget tests more concise and understandable, and writing them – faster and more fun.

It can be used on its own or with patrol_cli.

Installation #

$ dart pub add patrol --dev

Usage #

Patrol has 2 main features – native automation and custom finders.

Read our docs to learn more about them!

Accessing native platform features #

// example/integration_test/example_test.dart
import 'package:example/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';

void main() {
  patrolTest(
    'counter state is the same after going to home and going back',
    nativeAutomation: true,
    ($) async {
      await $.pumpWidgetAndSettle(const MyApp());

      await $(FloatingActionButton).tap();
      expect($(#counterText).text, '1');

      await $.native.pressHome();
      await $.native.pressDoubleRecentApps();

      expect($(#counterText).text, '1');
      await $(FloatingActionButton).tap();
      expect($(#counterText).text, '2');

      await $.native.openNotifications();
      await $.native.pressBack();
    },
  );
}

Custom finders #

import 'package:example/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:patrol/patrol.dart';

void main() {
  patrolTest(
    'logs in successfully',
    ($) async {
      await $.pumpWidgetAndSettle(const MyApp());

      await $(#emailInput).enterText('user@leancode.co');
      await $(#passwordInput).enterText('ny4ncat');

      // Finds all widgets with text 'Log in' which are descendants of widgets with key
      // box1, which are descendants of a Scaffold widget and tap on the first one.
      await $(Scaffold).$(#box1).$('Log in').tap();

      // Finds all Scrollables which have Text descendant
      $(Scrollable).containing(Text);

      // Finds all Scrollables which have a Button descendant which has a Text descendant
      $(Scrollable).containing($(Button).containing(Text));

      // Finds all Scrollables which have a Button descendant and a Text descendant
      $(Scrollable).containing(Button).containing(Text);
    },
  );
}
515
likes
0
pub points
95%
popularity

Publisher

verified publisherleancode.co

Powerful Flutter-native UI testing framework overcoming limitations of existing Flutter testing tools. Ready for action!

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

fixnum, flutter, flutter_test, grpc, http, integration_test, meta, path, protobuf, test_api

More

Packages that depend on patrol