---
title: 'Espresso Android Testing in Kotlin: Free Online Course'
description: 'Learn Espresso Android testing in Kotlin: Gradle setup, matchers and
  actions, RecyclerView and intents, IdlingResources, test isolation, then run the
  suite on cloud devices from CI. Free and hands-on.'
source_url:
  html: https://testingbot.com/resources/courses/espresso
  md: https://testingbot.com/resources/courses/espresso.md
---

Course

[Espresso Android Testing in Kotlin](https://testingbot.com/resources/courses/espresso)

Chapter 1 of 10

1. [1 Espresso Android Testing Tutorial in Kotlin](https://testingbot.com/resources/courses/espresso)
2. [2 Gradle Setup and Your First Espresso Run](https://testingbot.com/resources/courses/espresso/gradle-setup)
3. [3 ViewMatchers, ViewActions and ViewAssertions](https://testingbot.com/resources/courses/espresso/matchers-actions-assertions)
4. [4 Lists with RecyclerViewActions, and Espresso-Intents](https://testingbot.com/resources/courses/espresso/recyclerview-and-intents)
5. [5 Synchronisation and IdlingResources](https://testingbot.com/resources/courses/espresso/synchronisation-and-idling-resources)
6. [6 Test Isolation, Orchestrator and the Robot Pattern](https://testingbot.com/resources/courses/espresso/test-isolation-and-robots)
7. [7 Building the App APK and the Test APK](https://testingbot.com/resources/courses/espresso/build-the-apks)
8. [8 Run Espresso Tests on TestingBot](https://testingbot.com/resources/courses/espresso/run-on-testingbot)
9. [9 Running Espresso in CI with GitHub Actions](https://testingbot.com/resources/courses/espresso/ci-github-actions)
10. [10 Espresso Knowledge Check](https://testingbot.com/resources/courses/espresso/knowledge-check)

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

 Chapter 1 of 10 Intermediate 6 min read 1 quick check Updated Nov 2026 

# Espresso Android Testing Tutorial in Kotlin

Learn Espresso Android testing in Kotlin: Gradle setup, matchers and actions, RecyclerView and intents, IdlingResources, test isolation, then run the suite on cloud devices from CI. Free and hands-on.

## What you will learn

1. Espresso Android Testing Tutorial in Kotlin
2. [Gradle Setup and Your First Espresso Run](https://testingbot.com/resources/courses/espresso/gradle-setup)
3. [ViewMatchers, ViewActions and ViewAssertions](https://testingbot.com/resources/courses/espresso/matchers-actions-assertions)
4. [Lists with RecyclerViewActions, and Espresso-Intents](https://testingbot.com/resources/courses/espresso/recyclerview-and-intents)
5. [Synchronisation and IdlingResources](https://testingbot.com/resources/courses/espresso/synchronisation-and-idling-resources)
6. [Test Isolation, Orchestrator and the Robot Pattern](https://testingbot.com/resources/courses/espresso/test-isolation-and-robots)
7. [Building the App APK and the Test APK](https://testingbot.com/resources/courses/espresso/build-the-apks)
8. [Run Espresso Tests on TestingBot](https://testingbot.com/resources/courses/espresso/run-on-testingbot)
9. [Running Espresso in CI with GitHub Actions](https://testingbot.com/resources/courses/espresso/ci-github-actions)
10. [Espresso Knowledge Check](https://testingbot.com/resources/courses/espresso/knowledge-check)

[Continue where you left off](https://testingbot.com#)

## TestingBot Espresso Certification

Turn this course into a free, resume-worthy credential: pass the exam, run the course suite on TestingBot, and get a verifiable certificate for your LinkedIn profile.

[How it works](https://testingbot.com/resources/courses/espresso/certification)On this page
1. [Why Espresso tests are fast and stable](https://testingbot.com#why-espresso-tests-are-fast-and-stable)
2. [Espresso, UI Automator, Appium: honest trade-offs](https://testingbot.com#espresso-ui-automator-appium-honest-trade-offs)
3. [What you will build](https://testingbot.com#what-you-will-build)
4. [Prerequisites](https://testingbot.com#prerequisites)

_Last reviewed November 2026 against Espresso 3.7.0, AndroidX Test runner 1.7.0, Android Gradle Plugin 9.5.1, Gradle 9.6.1 and the TestingBot CLI (@testingbot/cli) 1.5.0._

Espresso is Google's UI testing framework for Android apps. It is part of AndroidX Test, it ships with every new Android Studio project, and it is what most Android developers mean when they say "instrumented UI tests". An Espresso test is ordinary Kotlin or Java that runs on an emulator or a phone, inside the same process as your app, and drives the real screens: it types into fields, taps buttons, scrolls lists and checks what is displayed.

This course builds a small Espresso suite for a tiny shop app, step by step, and ends with the same suite running on cloud devices from a GitHub Actions workflow. Here is the first test you will write, from chapter 2:

```kotlin
@Test
fun validLoginOpensProducts() {
    onView(withId(R.id.username)).perform(typeText("alice"))
    onView(withId(R.id.password)).perform(typeText("secret"), closeSoftKeyboard())
    onView(withId(R.id.login)).perform(click())

    onView(withId(R.id.welcome)).check(matches(withText("Welcome, alice")))
}
```

Every Espresso statement has the same three parts: **find** a view (`onView(withId(...))`), **do** something to it (`perform(...)`) or **check** it (`check(matches(...))`). There is no wait anywhere, although the login in this app takes one and a half seconds. Chapter 4 explains why that works and what you have to add to make it work.

## Why Espresso tests are fast and stable[#](https://testingbot.com#why-espresso-tests-are-fast-and-stable)

Espresso runs inside your app. The test APK is installed next to the app APK, and Android's instrumentation starts both in one process. That gives Espresso something an outside tool does not have: it can see the app's main thread. Before every action and every check, Espresso waits until the main thread has no pending messages and no registered background work is running. Only then does it touch the UI. Most of the timing problems that make UI tests flaky, such as tapping a button before the screen has finished drawing, never happen.

The second reason is that views are found by the same `R.id` constants the app uses. The Kotlin compiler checks them: if someone deletes `R.id.login`, the test stops compiling instead of failing at run time on a device.

## Espresso, UI Automator, Appium: honest trade-offs[#](https://testingbot.com#espresso-ui-automator-appium-honest-trade-offs)

Espresso is not the only way to test an Android app, and it is not the right tool for every test. A short comparison of the options you will hear about:

| | Espresso | UI Automator | Appium (UiAutomator2 driver) |
| --- | --- | --- | --- |
| Runs | Inside the app's process | On the device, outside the app | A server drives the device from outside |
| Needs app source | Yes, the test is compiled with it | No | No |
| Languages | Kotlin, Java | Kotlin, Java | Any WebDriver client: Java, JavaScript, Python, ... |
| Waiting | Automatic for the main thread, plus IdlingResources | Explicit waits (`wait(Until...)`) | Explicit or implicit waits |
| Can leave the app | No: system dialogs, notifications and other apps are out of reach | Yes | Yes |
| iOS from the same tests | No | No | Partly: same client code, different locators |

In practice:

- **Choose Espresso** for screen-level tests owned by the Android developers: forms, lists, navigation inside the app, error states. It gives the fastest and most stable feedback of the three.
- **Add UI Automator** where a test has to leave the app: a runtime permission dialog, a notification, the system settings. Both libraries can be used in the same test, because both come from AndroidX Test.
- **Choose Appium** when the tests are written by a separate QA team, must cover iOS and Android with one codebase, or cannot touch the app's source. The [Appium with WebdriverIO course](https://testingbot.com/resources/courses/appium-webdriverio) covers that path, and [Appium vs Espresso](https://testingbot.com/appium-vs-espresso) compares the two in more depth.

If your app is written with **Jetpack Compose** , the Compose screens are tested with the Compose testing APIs (`createComposeRule`, `onNodeWithText`) rather than `onView`. They run on the same AndroidX Test runner and integrate with Espresso's synchronisation, so everything in this course about Gradle, test isolation, building the test APK and running in the cloud still applies. This course uses classic Android views, which is where `onView` works.

A test must tap "Allow" on Android's runtime permission dialog before checking the camera screen. What do you use?

 Espresso's `onView(withText("Allow")).perform(click())` UI Automator for the dialog, Espresso for the app's own screens A `Thread.sleep` until the dialog disappears by itself

The permission dialog belongs to the system, not to your app's view hierarchy, so Espresso cannot see it. UI Automator can, and both libraries work in the same test. Waiting does not help: the dialog stays until someone answers it.

## What you will build[#](https://testingbot.com#what-you-will-build)

The sample is an app called Espresso Shop, small enough to read in five minutes and big enough to show every technique:

- a **login screen** whose "network call" runs on a background thread for 1.5 seconds,
- a **product list** of 50 items in a `RecyclerView`, each with an Add button,
- a **Help button** that opens a web page in the browser through an `Intent`.

The course shows every file of it that matters. The tests grow chapter by chapter:

1. Gradle setup: dependencies, the instrumentation runner, running tests on an emulator.
2. Finding views, performing actions and checking results.
3. Lists with `RecyclerViewActions`, and stubbing intents with Espresso-Intents.
4. Synchronisation: why Espresso rarely needs sleeps, and IdlingResources for when it does.
5. Test isolation with Android Test Orchestrator, and the robot pattern for readable tests.
6. Building the app APK and the test APK, and running filtered subsets.
7. Running the suite on TestingBot's Android emulators and real devices.
8. Running it from GitHub Actions on every push.

A knowledge check closes the course, and a free certification exam is available for those who want it.

## Prerequisites[#](https://testingbot.com#prerequisites)

- **Android Studio** , or the Android SDK command-line tools with an emulator image. This course used an Android 15 (API 35) emulator.
- **JDK 17.** The Android Gradle Plugin needs it to run; newer JDKs work for the build too, but 17 is the safe choice.
- **Basic Kotlin** : functions, lambdas and classes. No prior testing experience is needed.
- **For chapters 7 and 8:** Node.js (for the TestingBot CLI) and a TestingBot account.

If you are new to mobile testing in general, the [Mobile App Testing course](https://testingbot.com/resources/courses/mobile-app-testing) explains emulators versus real devices and how Espresso compares with XCUITest and Maestro.

[Next · Chapter 2 Gradle Setup and Your First Espresso Run](https://testingbot.com/resources/courses/espresso/gradle-setup)

On this page

1. [Why Espresso tests are fast and stable](https://testingbot.com#why-espresso-tests-are-fast-and-stable)
2. [Espresso, UI Automator, Appium: honest trade-offs](https://testingbot.com#espresso-ui-automator-appium-honest-trade-offs)
3. [What you will build](https://testingbot.com#what-you-will-build)
4. [Prerequisites](https://testingbot.com#prerequisites)

Certification

Earn the free, resume-worthy TestingBot Espresso Certification for this course.

[How it works](https://testingbot.com/resources/courses/espresso/certification)

## Other free courses

- [Mobile App Testing: From First Test to CI A free, hands-on mobile app testing course: emulators vs real devices, Appium vs Espresso vs XCUITest vs Ma...](https://testingbot.com/resources/courses/mobile-app-testing)
- [Accessibility Testing Tutorial: WCAG 2.2 A free, hands-on accessibility testing course: WCAG 2.2 in practice, manual keyboard and screen reader chec...](https://testingbot.com/resources/courses/accessibility-testing)
- [Selenium Locators and Locator Strategies A free course on Selenium locators and locator strategies: CSS selectors, XPath, role-based and test-id loc...](https://testingbot.com/resources/courses/locator-strategies)
- [Flaky Tests: Find, Fix and Prevent Fix flaky tests for good: measure them, then remove the four root causes (waits, shared data, test order, r...](https://testingbot.com/resources/courses/flaky-tests)

[Browse all courses](https://testingbot.com/resources/courses)
