Exit course
Chapter 10 of 10 Intermediate 6 min read Updated

Espresso Knowledge Check

Ten questions on the whole course. Answer them all, then press Check answers: the explanations appear under each question. This is a self-check; the certification exam has its own questions.

1. Your team wants UI tests for an Android app's checkout screens, written by the Android developers and run on every pull request. Which tool fits best?

Screen-level tests owned by app developers are Espresso's home ground: same language and project as the app, compile-checked ids and automatic synchronisation. All three tools run on emulators, and UI Automator is for the parts outside the app.

2. A new test class compiles, but the run reports "The @Rule 'activityRule' must be public". What is wrong in the Kotlin code?

Without the get: target, Kotlin puts the annotation on the private backing field, and JUnit rejects it. @get:Rule annotates the public getter.

3. onView(withId(R.id.price)) throws AmbiguousViewMatcherException on a cart screen. What does that tell you?

Ambiguous means "several matches". Row layouts reuse ids, so each visible row contributes one. Target a row with RecyclerViewActions or narrow the matcher.

4. A field has a text watcher that formats a phone number as you type. Which action exercises it like a user would?

typeText types character by character through the keyboard, so the watcher sees each keystroke. replaceText sets the whole value at once, which is faster but skips the per-character behaviour.

5. You need to tap the Delete button in the row that shows "Invoice 1043", somewhere far down a RecyclerView. Which approach works?

The row is off screen, so plain onView cannot find it (options a and d). actionOnItem scrolls to it first; a plain click() taps the row's centre, not the Delete button, so you need an action that clicks the child view.

6. A "Call us" button starts ACTION_DIAL. What should the test assert, and how?

The app's responsibility ends at sending the correct intent. Espresso-Intents verifies exactly that, and the stub keeps the dialer from opening. Testing the dialer itself tests someone else's app.

7. A screen uses Handler(Looper.getMainLooper()).post { ... } to update a label. Does the test need an IdlingResource to wait for it?

Espresso waits until the main thread's queue has nothing due. A post to the main looper is in that queue. IdlingResources are for work Espresso cannot see, such as other threads.

8. A suite passes with Gradle on your emulator, but on a device cloud some tests fail with leftover data from earlier tests. What is the most likely difference?

Orchestrator is configured in Gradle, not in the APKs, so it only helps where Gradle launches the tests. Tests that reset their own state pass in both places.

9. Which pair of files does TestingBot need for an Espresso run?

The cloud runs compiled code, like adb does: the app plus the instrumentation APK that contains the tests and the runner. YAML flows are Maestro, and JUnit XML is an output, not an input.

10. In GitHub Actions, the TestingBot step reports failed tests, but the workflow run is green. What is the first thing to check?

The CLI exits non-zero when tests fail, which fails the step and the run, unless something in the workflow ignores the exit code. (--async would make it worse: the CLI returns before any result exists.)

You finished Espresso Android Testing in Kotlin

Put what you learned into practice. Run your tests on 6100+ real browsers and physical iOS and Android devices.