Manabie Tech Blog

Sharing the humble technical knowledge we’re using to improve education

Running Flutter integration tests in Docker

Running Flutter integration tests in Docker



  • Flutter:

    • Google’s SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.
  • Docker:

  • Android Emulator container:

Why we use Docker to run automation tests

  • Scaling tests:

    • Docker provides the ability to package and run an application in a loosely isolated environment, so we can run multiple e2e tests parallel.
  • Reusing:

    • Our Dockerfile file and docker-compose.yml file is simple because of reusing container from the community.
  • Consistency:

    • Allowing developers to work in standardized environments using local containers which provide applications and services
  • Responsive:

    • Docker containers can run on a developer’s local laptop and on cloud providers.


  • We create Dockerfile for the flutter-app service because we need to copy our source code to the container to build then run tests
FROM cirrusci/flutter:2.8.1

RUN sdkmanager "build-tools;29.0.2"

RUN flutter precache --android --no-web --no-ios --no-universal

COPY pubspec.* .

RUN --mount=type=cache,sharing=locked,target=/flutter flutter pub get

WORKDIR /project

COPY . .
  • To run the Flutter integration test we need a process for Android Emulator and a process for Flutter drive. That is why we have 2 services: flutter-app and android-emulator in docker-compose.yml file.
version: "3.9"
      - /dev/kvm

      - android-emulator
    build: .
    command: make run-test
  • But flutter-app and android-emulator are 2 separate services. It means they are not the same network, so we need to connect flutter-app to android-emulator by the following command: adb connect android-emulator:5555. Reference:

  • After flutter-app connected to android-emulator, we can run the Flutter integration tests with flutter drive command. We combine connect emulator script and flutter drive script in run-test command in Makefile.

	sleep 10
	adb connect android-emulator:5555
	adb wait-for-device
	flutter pub get
	flutter drive --target test_driver/app.dart

Run the example

All tests passed!


  • Using docker for automation tests is being used widely in the software industry, not only Mobile field.
  • With Docker’s ability, scaling tests is far easier and faster, helping us to detect breakings and bugs quickly to fix and maintain.
  • Maybe you have the same question as almost all mobile developers who’re using macOS to work. How can we run the automation tests on macOS before shipping the source code to the cloud?
    1. We can’t run android-emulator x64 container on macOS because the macOS doesn’t have KVM.
    2. Actually, we can run android-emulator arm with -no-accel but the performance is very bad => can’t use on Intel chip macOS
    3. Running android-emulator arm on ARM chip macOS:
    4. Connecting flutter-app service from container to Android Emulator on macOS, yes we can do that I will write a blog for this.


comments powered by Disqus