Why run tests in CI?
Automated testing in CI provides several benefits:- Early bug detection - Catch issues before they reach production
- Consistent test environment - Run tests in the same environment every time
- Fast feedback - Get test results within minutes of pushing code
- Confidence in deployments - Deploy knowing your tests pass
CI/CD approaches
There are two main approaches to running mobile UI tests in CI:Device Labs
Upload app binaries to cloud-based testing services
Traditional CI
Run tests directly on CI runners with emulators/simulators
Device labs
Device labs provide access to real devices and emulators in the cloud. You upload your app and test APKs/IPAs, select devices, and the service runs tests and reports results. Advantages:- Easy to set up and use
- Access to real devices
- Stable and maintained infrastructure
- Video recordings and detailed reports
- Firebase Test Lab - Google’s testing infrastructure
- emulator.wtf - Fast Android emulator testing
- BrowserStack - Real device testing
- LambdaTest - Cloud testing platform
Traditional CI
With traditional CI, you have full control over the testing environment. You script everything: installing SDKs, creating virtual devices, running tests, and collecting results. Advantages:- Complete flexibility
- No file upload/download overhead
- Direct access to test artifacts
- Can test complex scenarios (e.g., camera manipulation)
- Requires more setup and maintenance
- Emulator stability can be challenging
- Longer execution times on some platforms
Platform-specific guides
Choose your CI/CD platform to get started:GitHub Actions
Run Patrol tests with GitHub Actions
GitLab CI
Integrate Patrol with GitLab pipelines
Bitrise
Configure Patrol for Bitrise workflows
Basic workflow
Regardless of your CI platform, the basic workflow is:Performance tips
Caching
Cache these directories to speed up your builds:- Flutter SDK (
~/.flutter) - Pub cache (
~/.pub-cache) - Gradle dependencies (
~/.gradle) - CocoaPods (
ios/Pods)
Parallel execution
Run tests in parallel across different:- Device models
- OS versions
- Test suites (using tags)
Test selection with tags
Patrol supports tag-based test filtering, which is perfect for CI:Common challenges
Android emulator stability
iOS simulator limitations
iOS simulators are faster than Android emulators but have limitations:- No easy way to simulate network conditions
- Cannot test certain hardware features
- Behavior may differ from real devices
Build times
First builds in CI can be slow. Use these strategies:- Cache dependencies aggressively
- Use
flutter precacheto download platform artifacts - Run
flutter build --config-onlyto generate build files without building
Next steps
GitHub Actions
Complete GitHub Actions setup guide
Firebase Test Lab
Learn about device lab testing