Run Android Tests on Real Phones in GitHub Actions
说明与用途
GitHub Actions 工作流连接到真实 Android 设备,安装 APK,运行仪器化测试,并安全断开,确保可靠的硬件特定测试。
问题
CI pipelines using emulators fail to detect hardware‑specific issues, leading to green builds that miss real‑device bugs.
结果
The workflow reliably runs Android tests on real devices, handling flaky connections, ensuring clean device state, and preventing test collisions via concurrency groups.
工作流
- Checkout repository
- Set up Android SDK and platform‑tools
- Build debug APK
- Connect to device with retry loop
- Install APK on device
- Run instrumented tests
- Disconnect device (always)
证据
Emulators in CI are fine until your app cares about being on a real device.
The loop in the first block handles that: connect, wait, check that the state is device, and only then move on.
A concurrency group makes device jobs queue instead of colliding.
- 记录日期: 2026-10-06T09:55:56.412Z