Android Testing Support Library announced

During the Droidcon UK 2014, Stephan Linzner of Google announced the upcoming Android Testing Support Library. This means Google is (finally) taking testing Android apps seriously.

The library is a unbundled static testing library for Android that containers all Android testing frameworks by Google. It will become a available through the Android Support repository and as open source in AOSP.

So what does it contain?

  • AndroidJUnitRunner
    This Runner, based on android.test.InstrumentationTestRunner, runs JUnit3 and JUnit4 tests against an Android package (application). Let me give an example:

    @RunWith (JUnit4.class)
    public class MyJUnit4Test {
      Droidcon mDroidconUK;
      public void setUp() {
        mDroidconUK = new Droidcons.get(Droidcon.UK);;

      public void checkPreconditions() {
        assertNotNull("mDroidconUK cannot be null", mDroidconUK);

      public void tearDown() {

  • Espresso
    Introduced at the GTAC in 2013, Espresso makes it possible to write concise, beautiful, and reliable Android UI tests quickly. Lets look at some examples:

    // Find view using a Matcher and type text using a ViewAction
    onView(withId(, closeSoftKeyboard());

    // Perform a click ViewAction

    // Verify using a ViewAssertion

  • Intento
    Intento is like Mockito but for Intents. Basically a mock framework that allows you to create and configure mock objects. Let me give you an example:

    public void testDailerInput_typeNumberAndCall() {
      //Type phonenumber in dialer
      onView(withId(, typeText("123-345-6789"), closeSoftKeyboard());
      // Click the call button
      onView(withId(, click());
      //Validate Intent has been send
          hasData(allOf(hasSchemaSpecificPart("tel", "123-345-6789")))),

In conclusion: Testing with Android is finally becoming a more prominent part of Android Development cycle with the introduction of the Android Testing Support Library

  1. Jay Khimani
    Thanks for sharing the update on this much awaited library. btw, in your example JUnit, I guess you meant to have @Ater on tearDown instead @Before.
  2. W.Elsinga
    Thanks for the correction

Leave a Reply


captcha *

This site uses Akismet to reduce spam. Learn how your comment data is processed.