Patrol 2.0 is here!

Patrol 2.0 is the new major version of Patrol.


  • Advanced test bundling feature provides deep and seamless integration with existing Android and iOS testing tools. It also fixes some long-standing Flutter issues:

    This is huge (even though it may not look like it at first glance). To learn more, read the in-depth technical article explaining the nuts and bolts.

  • Improved scrolling and pumping makes methods such as tap(), enterText(), and scrollTo() more reliable and easier to use. For example, they no longer throw an error if there's an infinite animation.

Migration guide#

Patrol 2.0 contains a few breaking changes.

Fortunately, they're small and mostly touch only boilerplate and configuration files. The code of tests written in Dart stays the same (with some minor exceptions - see the Caveats section below).


  • Update the dependency in pubspec.yaml:

      patrol: ^2.0.0
  • Make sure you're using the newest version of Patrol CLI. It should begin with v2:

    $ patrol --version
    patrol_cli v2.0.0
  • The file test_bundle.dart in the integration_test directory should be added to gitignore. It's automatically generated by Patrol CLI at build time.

  • In your tests, rename scrollTo()'s argument scrollable to view.


  • MainActivityTest.java

    Contents of this file have to be replaced. It's located your application's android/app/src/androidTest/java/com/example/myapp/ directory (replacing com, example, and myapp with values from your app's package name).

    package pl.leancode.patrol.example; // replace "pl.leancode.patrol.example" with your app's package
    import androidx.test.platform.app.InstrumentationRegistry;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.junit.runners.Parameterized;
    import org.junit.runners.Parameterized.Parameters;
    import pl.leancode.patrol.PatrolJUnitRunner;
    public class MainActivityTest {
        @Parameters(name = "{0}")
        public static Object[] testCases() {
            PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
            return instrumentation.listDartTests();
        public MainActivityTest(String dartTestName) {
            this.dartTestName = dartTestName;
        private final String dartTestName;
        public void runDartTest() {
            PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
  • build.gradle

    A few changes are also needed in app-level build.gradle:

    android {
      // ...
      defaultConfig {
        testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner"
      // ...
      testOptions {
    dependencies {
      androidTestUtil "androidx.test:orchestrator:1.4.2"

    To achieve full isolation between test runs, enable the clearPackageData option:

    defaultConfig {
      testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner"
      testInstrumentationRunnerArguments clearPackageData: "true"

    This will clear the app's data and permissions before each test run. Unfortunately, no equivalent feature is available on iOS.

    If you had testImplementation "junit:junit:4.13.2" (or similar) in dependencies block, it should be removed.


On iOS, only one line has to be added in the RunnerUITests.m file. Simply copy and paste these contents:

@import XCTest;
@import patrol;
@import ObjectiveC.runtime;


That's all!


There are a few, and all are kept track of in this issue. We intent to fix all of them in future releases.