Android Espresso Cheat Sheet



チェンチュー[Chiu-Ki Chan]

Rio funk backing track. @chiuki
+ChiuKiChan Tikka t3x veil wideland price.

Espresso is a testing framework for writing UI tests in Android. According to the official docs, you can: Use Espresso to write concise, beautiful, and reliable Android UI tests. Why Use Espresso? One of the problems with manual testing is that it can be time-consuming and tedious to perform. SEE: Android 11: A cheat sheet (free PDF) (TechRepublic) With 85.4% of the global smartphone market share, Android still reigns supreme, according to IDC. Because Android 11 rolled out faster than.

Automatic UI testing

Espresso Workflow Is Simple to Use. The way Espresso works is by allowing developers to build a. A complete list of the available ObjectMatcher, DataOptions, ViewAction, and ViewAssertion can be found in this Espresso Cheat Sheet. Let’s have a look at a simple example that finds a list item of. You can run your tests in Android Studio or from the command line. In Android Studio. To create a test configuration in Android Studio, complete the following steps: Open Run Edit Configurations. Add a new Android Tests configuration. Choose a module. Add a specific instrumentation runner: androidx.test.runner.AndroidJUnitRunner.

Espresso

  • Android Testing Support Library
  • Simulate user interactions
  • Automatic synchronization of test actions with app UI


No need to sleep

Formula

ViewMatcher

ViewAction

ViewAssertion

More info

  • github.com/chiuki/espresso-samples under hello-world

Espresso library

Hamcrest

Espresso

developer.android.com/training/testing/espresso/cheat-sheet.html

Hamcrest

marcphilipp.de/downloads/posts/2013-01-02-hamcrest-quick-reference/Hamcrest-1.3.pdf

Toolbar title

Hierarchy Viewer

isAssignableFrom

Espresso

toolbar.getTitle()

toolbar.getTitle()

  • Verify the Toolbar
  • TextMatcher instead of String

More info

Sheet
  • github.com/chiuki/espresso-samples under toolbar-title

Formula

ListView

App

App

App

Test

withValue

RecyclerView

RecyclerView

onData

RecyclerViewActions

actionOnItemAtPosition
  • actionOnHolderItem with Matcher<VH>
  • actionOnItem with Matcher<View>

More info

  • github.com/chiuki/espresso-samples under list-view-basic
  • github.com/chiuki/espresso-samples under recycler-view-basic

Espresso Idle

  • No UI events queued
  • No tasks in AsyncTask thread pool

Custom IdlingResource

Define your own condition

e.g. IntentService is not running.

IntentServiceIdlingResource

isIntentServiceRunning()

Register

More info

Dagger

Android Espresso Cheat Sheet

Dependency injection.

Different objects for app and test.

Mockito

Mock objects in test.

Dagger components

Application

MockApplication

Android Espresso Cheat Sheet Free

MockTestRunner

build.gradle

Mockito

More info

Summary

Android Espresso Cheat Sheet 2020

  • Matcher, ViewAction, ViewAssertion
  • Combining matchers
  • Custom matchers
  • ListView
  • RecyclerView
  • Idling Resource
  • Dagger and Mockito

Friend Spell

Android Espresso Cheat Sheet

  • Google Plus
  • Nearby API
  • Database

  • Dagger
  • Mockito
  • JUnit
  • UI-less instrumentation
  • Espresso

Thank you!

  • bit.ly/advesp
  • github.com/chiuki/espresso-samples
  • github.com/chiuki/android-test-demo
  • github.com/chiuki/friendspell
  • bit.ly/pluralsight-chiuki
  • gumroad.com/chiuki
  • techspeak.email
  • blog.sqisland.com
  • @chiuki
  • +ChiuKiChan
  • tinyletter.com/sqisland

In an older post from 2013 I briefly described the Android test automation tool called Espresso. Espresso is the test automation framework provided by Google to implement fast and reliable tests for Android apps. Since last year Espresso is available in the version 2.0 and has fixed lots of issues and is now supporting most of the Android UI elements. If you are new to Espresso you can check the following URLs, they provide a getting started, Espresso guide and some Espresso samples.

URLs:

  • Espresso Setup
  • Espresso Getting Started
  • Espresso Samples on GitHub

Today I found the Espresso Cheat Sheet (I don’t know why this not happened earlier 🙂 ), but nevertheless I want to share it with you as well. Read more