DocuSign Dev Blog

Brought to you by the development teams at DocuSign

Americano, made with an improved Espresso machine.

Today we are publishing Americano, an open source Android library of helpers to build on top of Espresso, an Android API by Google for writing reliable UI tests. Along with the release of Americano, we also want to cover the useful improvements we’ve made to our own fork of Espresso.

The two are meant to be used together, but if need be, Americano can be used completely with the current version of Espresso released by Google.

Espresso: Faster Running and Debugging


When running functional UI tests, the biggest drain is almost always time. At first we felt an excessive drain with Espresso, especially if any test required a waitFor(time, assert) assertion. We found that if the app moved between root windows at all during the test (e.g. started a new activity, or opened a dialog) the assertion would wait for the full time requested before finding the most present window and performing the assertion.

To fix this, Espresso now maintains multiple root windows and listens for them to be added rather than waiting to update the selected window at specific times. This allows us to follow all view hierarchy changes and assert as soon as the view we are looking for is present.


Possibly the most useful of the improvements, Espresso will now capture screenshots leading up to a test failure and the final screenshot of where an assertion or attempted action failed. This makes debugging the view hierarchy that is printed to the console by Espresso quick and easier to understand. Espresso will dump only the failure screenshots into the test results directory.

Americano: Describing the Finer Details

With Americano, our goal was to provide a few more useful methods for describing a specific view among a giant group of similar views. For that, we’ve added a few different types of View “Matchers” for Espresso.

Dimensional Matchers

These are meant to help locate a view that should be next, overlapping or under another view. For this, we’ve added the DimensionalMatchers class. The dimensional matchers will find you any view that has the relation requested to your view.

Below, the matcher entirelyAbove is returning all views that are above and not overlapping “Forgot Password?”, and then asserting that “Log In” is one of them.

onView(withText("Log In"))
    .check(matches(is(entirelyAbove(withText("Forgot Password?")))));

Full list of dimensional helpers:

  • above, entirelyAbove
  • below, entirelyBelow
  • leftOf, entirelyLeftOf
  • rightOf, entirelyRightOf

Ranking Matchers

Along with the relational helpers, there is also a class of RankingMatchers. The ranking matchers will find the leftmost, lowest or even widest view by the description given.

onView(lowest(withText("Log In")))

Full list of ranking matchers:

  • mostleft
  • mostright
  • lowest
  • highest
  • widest
  • skinniest
  • tallest
  • shortest

These improvements to Espresso and additions of Americano have helped immensely while creating a robust and reliable test suite for Android. Have a look at Americano and our Espresso fork to get going.

Be sure to send any virtual high fives to the developers that made this happen: @tophyr, @abeatte and @stephenparish.

comments powered by Disqus