← All posts

Espresso testing on cloud Android (CI ready)

Sep 12, 2026 · By Xavier Fok

The gap between passing tests and real bugs

Your Espresso suite passes in CI and then breaks in production the first week a real device gets its hands on it. The bug is real-device-only: animations, vsync timing, sensors, accessibility services. None of that reproduces inside an emulator’s virtual machine, and if your CI only runs emulators, that gap is exactly what’s eating your release confidence.

The workflow: Android Studio without the USB cable

Running Espresso on a cloud phone doesn’t change how you write tests. Espresso is an instrumentation framework: it ships inside your test APK, runs in the same process as the app under test, and reports results through AndroidJUnitRunner. None of that cares what device it’s running on. Any device reachable over ADB can run it, whether that’s a phone on your desk or one sitting in a rack somewhere else.

That’s what makes cloud phones useful here. Espresso earns its keep on real-device behavior: gestures, animations, scroll inertia, the soft keyboard, accessibility events. Those are the things an emulator fakes and a cloud phone actually does.

This piece covers three things: a Gradle setup that targets a cloud phone over the network, idling resources for clean async assertions, and running tests in parallel across multiple cloud phone serials.

Why real hardware beats emulators here

Espresso runs in-process with the app under test, which gives it sub-frame precision on view hierarchy assertions. That precision is only as good as the device it’s running on. Emulators introduce their own unpredictability: x86 translation layers and host OS scheduler noise both get in the way. A cloud phone removes that noise because it’s real Samsung-class hardware running a real Android kernel, not a virtual machine pretending to be one.

Three categories of tests benefit the most. Animation-heavy UIs, where Espresso’s idling resource model handles real animations cleanly instead of faked ones. Multi-window edge cases like split screen and picture-in-picture. And accessibility tests, where TalkBack and Switch Access only behave correctly on real hardware.

Dependencies and prerequisites

Your Android project probably already has the Espresso dependencies. If not, add them to your app module’s build file the normal way.

On your laptop or CI runner you’ll need Java 17, the Android SDK, Android platform tools for ADB, and Gradle. Nothing about targeting a cloud phone changes this list.

Connecting and running your first test

Log into cloudf.one and copy the ADB endpoint for your test phone. With one device connected, the simplest run is the standard Gradle command:

./gradlew connectedAndroidTest

Gradle reads the connected device list, builds the test APK and the app APK, installs both, and runs the tests. Results land in app/build/reports/androidTests/connected.

If you have more than one device connected, pin Espresso to the cloud phone with the serial-targeted variant of the connected test task, so you know exactly which device ran which suite.

Writing a smoke test

Create app/src/androidTest/java/com/example/SmokeTest.kt the same way you would for any instrumentation test. Run it against the cloud phone with the serial flag. Results appear in HTML form at app/build/reports/androidTests/connected/index.html, same as any local run.

Idling resources for async work

Espresso’s most useful feature for a real app is the idling resource API. It lets a test wait for async work to finish without reaching for Thread.sleep. Call start() when a network call begins and stop() when it completes; Espresso blocks any UI assertion until the idler reports idle.

This works more reliably on cloud phones than on emulators for a simple reason: real device timing is consistent. Emulator scheduler noise makes idling resources flaky in ways that have nothing to do with your app’s actual async logic.

Running tests in parallel across cloud phones

Gradle’s connected test task runs against one device by default. To run in parallel across cloud phones, define multiple Gradle tasks, each pinned to a different device serial, and run them concurrently in CI.

cloudf.one’s REST API returns a list of currently locked devices, so you can wire a lock loop into your CI step: lock a phone, run the pinned task against its serial, release it when the job finishes.

Artifacts, pitfalls, and Jetpack Compose

For failure debugging, capture a screenshot and a screen recording alongside the test report so you’re not guessing at what the device actually showed.

Three pitfalls catch teams new to this. The soft keyboard: typeText doesn’t dismiss it automatically, so call closeSoftKeyboard() if later assertions fail because the keyboard is covering the view. Animations: disable system animations on the cloud phone with the settings put global commands for window, transition, and animator duration scale, or timing noise will show up as flaky tests. And test isolation: use the AndroidX Test Orchestrator, which runs each test in its own process and stops one test’s leftover state from breaking the next.

Espresso also works with Jetpack Compose. Add the compose-ui-test-junit4 dependency and use composeTestRule alongside your existing Espresso rules. Both run identically on a cloud phone.

The point of doing this on real hardware

cloudf.one runs real Samsung phones in Singapore on real Singtel, StarHub, and M1 SIMs. ADB over network is the standard connection method, so your existing Gradle setup works without changes. You’re swapping a USB cable for a hostname, not rewriting your test suite.

If you want to try this before committing your CI pipeline to it, use code YT30 for 30 off your first month. One phone is enough to run your full smoke suite end to end and confirm the result reports look right before scaling up to a fleet.

Ready to get your Espresso suite off the emulator? Head to cloudf.one and connect your first cloud phone.

Get new guides and videos first — join the Telegram channel.

40% off until 31 December 2026
Real phones in Singapore, each with its own mobile IP.
Introductory price until 31 December 2026. A dedicated phone straight away, no queue.