Patrol Flutter integration tests show "0 tests ran" on BrowserStack but pass locally
13:20 16 Dec 2025

I'm trying to run Patrol integration tests on BrowserStack, but test discovery fails with "0 tests ran" even though the same tests pass locally on an emulator.

Environment

  • Flutter 3.38.4
  • Patrol 4.0.1
  • Android target: Google Pixel 8 (Android 14 / API 34)
  • Using LeanCode's bs_android script from mobile-tools

Configuration

android/app/build.gradle.kts:

  android {
      defaultConfig {
          testInstrumentationRunner = "pl.leancode.patrol.BrowserstackPatrolJUnitRunner"
          testInstrumentationRunnerArguments["clearPackageData"] = "true"
      }

      testOptions {
          execution = "ANDROIDX_TEST_ORCHESTRATOR"
      }
  }

MainActivityTest.java:

  @RunWith(Parameterized.class)
  public class MainActivityTest {
      @Parameters(name = "{0}")
      public static Object[] testCases() {
          PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
          instrumentation.setUp(MainActivity.class);
          instrumentation.waitForPatrolAppService();
          return instrumentation.listDartTests();  // Returns empty on BrowserStack
      }

      private final String dartTestName;

      public MainActivityTest(String dartTestName) {
          this.dartTestName = dartTestName;
      }

      @Test
      public void runDartTest() {
          PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
          instrumentation.runDartTest(dartTestName);
      }
  }

What works

Running locally on emulator: patrol test -t patrol_test/app_test/login_screen_test.dart ✅ Tests discovered and executed successfully

What fails

Running on BrowserStack via bs_android:

export BS_CREDENTIALS="username:accesskey"
export BS_ANDROID_DEVICES='["Google Pixel 8-14.0"]'
bs_android -t patrol_test/app_test/login_screen_test.dart

BrowserStack instrumentation logs:

INSTRUMENTATION_RESULT: stream=

Time: 0

OK (0 tests)

INSTRUMENTATION_CODE: 0

Build status shows "status": "skipped" with "short_error_message": "No Tests Ran".

What I've investigated

Patrol's test discovery works via HTTP communication:

  1. Native side (test APK) runs PatrolServer on port 8081
  2. Dart side (app APK) runs PatrolAppService on port 8082
  3. Dart calls markPatrolAppServiceReady() via HTTP POST to localhost:8081
  4. Native calls listDartTests() via HTTP GET to localhost:8082

The BrowserstackPatrolJUnitRunner has a fallback that looks for a tun0 interface when localhost fails, but this doesn't appear to resolve the issue.

Question

How can I configure Patrol to work with BrowserStack's network environment? Is there a way to specify an alternative host/port for the native-Dart communication, or is there additional BrowserStack configuration required?

flutter integration-testing android-testing browserstack flutter-patrol