Search code examples
fluttercodemagicwidget-test-flutter

Codemagic: how do I set up integration tests Android Emulator


Here is how the default configuration for tests looks like:

enter image description here

In Flutter Drive arguments we can see that there is a target defined

drive --target=test_driver/main.dart

Flutter documentation on integration tests doesn't mention creating this file. So this folder with the respective file is missing in my project, which logically results into fail:

Target file "test_driver/main.dart" not found.

Here are the logs:

> flutter devices
3 connected devices:

Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
macOS (desktop)                    • macos         • darwin-x64     • macOS 12.4 21F79 darwin-x64
Chrome (web)                       • chrome        • web-javascript • Google Chrome 103.0.5060.114
> flutter -d emulator-5554 drive --target=test_driver/main.dart
Target file "test_driver/main.dart" not found.

The documentation on how to write integration tests only mentions test_driver when testing web.

Apparently I am either missing stuff in my project or I need to configure codemagic workflow differently.

There is a bit information here https://docs.codemagic.io/yaml-testing/testing/ for yaml configuration. Should i switch to yaml config, or can it be done from CodeMagic UI?

UPDATE: After I have change the configuration as mentioned in the answers to this:

enter image description here

The logs are now:

Test file not found: > /Users/builder/clone/test_driver/app_test_test.dart


Solution

  • The recommended approach per Flutter documentation is to use:

    flutter test integration_test
    

    Thus, in the arguments section in Codemagic, just add test integration_test.