---
title: Running Espresso and XCUITest Suites in the Cloud
description: Espresso and XCUITest tests are written by app developers, live in the
  app&#39;s repository and are compiled together with the app. Running them on a device…
source_url:
  html: https://testingbot.com/resources/courses/mobile-app-testing/espresso-and-xcuitest
  md: https://testingbot.com/resources/courses/mobile-app-testing/espresso-and-xcuitest.md
---

Course

[Mobile App Testing: From First Test to CI](https://testingbot.com/resources/courses/mobile-app-testing)

Chapter 7 of 10

1. [1 Mobile App Testing: What Makes It Different](https://testingbot.com/resources/courses/mobile-app-testing)
2. [2 Emulators, Simulators and Real Devices](https://testingbot.com/resources/courses/mobile-app-testing/emulators-simulators-and-real-devices)
3. [3 Choosing a Framework: Appium, Espresso, XCUITest, Maestro](https://testingbot.com/resources/courses/mobile-app-testing/choosing-a-framework)
4. [4 Uploading and Managing App Builds](https://testingbot.com/resources/courses/mobile-app-testing/app-builds-and-uploads)
5. [5 Your First Appium Test on a Real Device](https://testingbot.com/resources/courses/mobile-app-testing/first-appium-test)
6. [6 Your First Maestro Flow on TestingBot](https://testingbot.com/resources/courses/mobile-app-testing/first-maestro-flow)
7. [7 Running Espresso and XCUITest Suites in the Cloud](https://testingbot.com/resources/courses/mobile-app-testing/espresso-and-xcuitest)
8. [8 Device Matrix, Parallel Runs and CI](https://testingbot.com/resources/courses/mobile-app-testing/device-matrix-parallel-ci)
9. [9 Debugging Failed Mobile Test Runs](https://testingbot.com/resources/courses/mobile-app-testing/debugging-failed-runs)
10. [10 Knowledge Check](https://testingbot.com/resources/courses/mobile-app-testing/knowledge-check)

[Exit course](https://testingbot.com/resources/courses)

 Chapter 7 of 10 Beginner 5 min read 2 quick checks Updated Nov 2026 

# Running Espresso and XCUITest Suites in the Cloud
On this page
1. [What an Espresso test looks like](https://testingbot.com#what-an-espresso-test-looks-like)
2. [The two files an Espresso run needs](https://testingbot.com#the-two-files-an-espresso-run-needs)
3. [Run the suite](https://testingbot.com#run-the-suite)
4. [XCUITest: the same idea for iOS](https://testingbot.com#xcuitest-the-same-idea-for-ios)
5. [Native suites next to cross-platform ones](https://testingbot.com#native-suites-next-to-cross-platform-ones)

Espresso and XCUITest tests are written by app developers, live in the app's repository and are compiled together with the app. Running them on a device cloud works differently from Appium: you do not open a session and send commands. You upload two binaries, the app and the test bundle, and the platform's own test runner executes the whole suite on the device. This chapter runs an Espresso suite on TestingBot and explains the XCUITest equivalent.

## What an Espresso test looks like[#](https://testingbot.com#what-an-espresso-test-looks-like)

This is one of the tests in TestingBot's [Espresso demo app](https://github.com/testingbot/android-espresso-demo-app), from `CalculatorTest.java`:

```java
@Test
public void ensureAdditionWorks() {
    takeActivityScreenshot("addition_works");
    // Type text and then press the button.
    onView(withId(R.id.but3)).perform(click());
    onView(withId(R.id.butplus)).perform(click());
    onView(withId(R.id.but5)).perform(click());
    onView(withId(R.id.buteq)).perform(click());

    // Check that the text was changed.
    onView(withId(R.id.output)).check(matches(withText("8.0")));
}
```

Compare it with the Appium test from chapter 4. There are no waits at all: Espresso runs inside the app's process, sees when the main thread is idle and only then performs the next action. Views are found by their generated resource ids (`R.id.but3`), which the compiler checks. The price is that this test cannot exist without the app's source code, and it only runs on Android.

## The two files an Espresso run needs[#](https://testingbot.com#the-two-files-an-espresso-run-needs)

Gradle builds them from the same project:

```bash
./gradlew assembleDebug assembleDebugAndroidTest
```

That produces `app/build/outputs/apk/debug/app-debug.apk` (the app) and `app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk` (the tests plus the instrumentation runner). The demo project pins an older Gradle (6.5), which predates current JDKs: this course built it with JDK 11. The demo app's [1.0.0 release](https://github.com/testingbot/android-espresso-demo-app/releases/tag/1.0.0) has both prebuilt, which is what this chapter uses.

## Run the suite[#](https://testingbot.com#run-the-suite)

```bash
npx @testingbot/cli@1.5.0 espresso app-debug.apk app-debug-androidTest.apk \
  --device "Pixel 8" --platform-version "14" \
  --name "Calculator Espresso" --build "course-mobile-app-testing"
```

The CLI uploads both APKs, starts the run and streams the instrumentation output. On a Pixel 8 emulator with Android 14 the demo suite ran six tests: five passed and `AdvancedCalculatorTest.ensureLargeNumbersWork` failed (session `894e8d77c9a3-...`). That failure is known and deliberate in the 1.0.0 release: the test expects the wrong text. Chapter 8 uses it to practise reading a failed run.

To run part of a suite, the CLI passes the standard instrumentation filters through: `--class`, `--package`, `--annotation` and `--size`, plus `--not-` variants of each. Running only the calculator class:

```bash
npx @testingbot/cli@1.5.0 espresso app-debug.apk app-debug-androidTest.apk \
  --device "Pixel 8" --platform-version "14" \
  --class com.testingbot.calculator.CalculatorTest \
  --name "Calculator Espresso" --build "course-mobile-app-testing" \
  --report junit --report-output-dir ./reports
```

```
com.testingbot.calculator.CalculatorTest:
Time: 11.115
OK (5 tests)
  Run 3255 (Pixel 8): Test completed successfully
All tests completed successfully!
Saved report: reports/espresso_report_3234.xml
```

That run (session `76d9e25dbe51-...`, Pixel 8 emulator, Android 14) passed and saved a JUnit XML report that a CI system can display. For a physical phone, add `--real-device` and pick a real device name, for example `--device "Galaxy S24" --real-device`.

A developer changes a button label and wants to re-run the Espresso tests in the cloud. What has to be rebuilt and uploaded?

 Only the test APK Nothing; the cloud picks up the change from the repository The app APK, and the test APK too if any test changed Only the JUnit report

The label lives in the app, so the app APK must be rebuilt. If a test assertion was updated to match, the test APK changes as well. Both are compiled artefacts; nothing is fetched from source at run time.

## XCUITest: the same idea for iOS[#](https://testingbot.com#xcuitest-the-same-idea-for-ios)

An XCUITest run on TestingBot also takes two files, as the [XCUITest documentation](https://testingbot.com/support/app-automate/xcuitest) describes:

- the app as a signed **`.ipa`** , and
- the tests as a **`.zip`** of the `-Runner.app` that Xcode produces with _Product \> Build For \> Testing_ (or `xcodebuild build-for-testing`). [Build an XCUITest suite](https://testingbot.com/support/app-automate/xcuitest/build-testsuite) walks through finding and zipping it.

The documented CLI command has the same shape as Espresso's: `testingbot xcuitest app.ipa app-test.zip --device "iPhone 16" --real-device`.

This course did not run an XCUITest suite: the XCUITest sample ([xcuitest-example-app](https://github.com/testingbot/xcuitest-example-app)) is source code only, and turning it into an `.ipa` needs an Apple developer signing identity. The command is the form the documentation gives, not a run we can show you a result for. Everything else carries over from Espresso: filters for which tests to run, `--build` and `--name`, `--report junit`, `--retry`, and artifacts after the run.

You zip the folder `Build/Products/Debug-iphonesimulator` and upload it as the XCUITest suite for a real iPhone. The run fails to install the tests. Why?

 XCUITest zips must contain the source files That is a simulator build; a real device needs the `-Runner.app` built for devices (`Debug-iphoneos`) The zip must be renamed to `.ipa`

Simulator products cannot be installed on hardware, for tests as much as for apps. Build for testing against a generic iOS device and zip the `-Runner.app` from `Debug-iphoneos`.

## Native suites next to cross-platform ones[#](https://testingbot.com#native-suites-next-to-cross-platform-ones)

Running Espresso and XCUITest in the cloud gives developers what their own machines cannot: many OS versions and real hardware without a device drawer. It does not replace a cross-platform Appium or Maestro suite, because each native suite only covers one platform and is written by the people who wrote the code. Many teams run both: native suites on every pull request, a smaller end-to-end suite on both platforms before release. The [Espresso documentation](https://testingbot.com/support/app-automate/espresso) lists every option, including retries, timeouts, queue priority and the Gradle plugin that uploads and runs straight from your build.

[Previous · Chapter 6 Your First Maestro Flow on TestingBot](https://testingbot.com/resources/courses/mobile-app-testing/first-maestro-flow) [Next · Chapter 8 Device Matrix, Parallel Runs and CI](https://testingbot.com/resources/courses/mobile-app-testing/device-matrix-parallel-ci)

On this page

1. [What an Espresso test looks like](https://testingbot.com#what-an-espresso-test-looks-like)
2. [The two files an Espresso run needs](https://testingbot.com#the-two-files-an-espresso-run-needs)
3. [Run the suite](https://testingbot.com#run-the-suite)
4. [XCUITest: the same idea for iOS](https://testingbot.com#xcuitest-the-same-idea-for-ios)
5. [Native suites next to cross-platform ones](https://testingbot.com#native-suites-next-to-cross-platform-ones)

Certification

Earn the free, resume-worthy TestingBot Mobile App Testing Certification for this course.

[How it works](https://testingbot.com/resources/courses/mobile-app-testing/certification)
