Environment Setup

Set up Espresso

BitBar Testing has had Espresso support since its first versions. This guide shows how to set up Android Studio and Espresso v2.0. The same or a similar setup should work for Eclipse and Android SDK as well.

  1. In Android SDK, go to Tools > Android > SDK Manager.

    Opening the SDK Manager
  2. Make sure that Android Support Repository is installed. It is located under Extras.

    Android Support Repository
  3. Open the app/build.gradle file in a text editor and add the following code to dependencies:

    androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
    androidTestCompile 'com.android.support.test:runner:1.0.1'

    If the application under test uses functionality from espresso-contrib, add the following code to dependencies as well:

    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:3.0.1'
  4. Configure the instrumentation runner with the testInstrumentationRunner parameter. The build.gradle file should look like this:

    defaultConfig {
      applicationId "com.example.bbexample.myapplication"
      minSdkVersion 15
      targetSdkVersion 26
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

For more information about Espresso Resource, see:



AndroidJUnitRunner is a new unbundled test runner for Android, which is part of the Android Support Test Library and can be downloaded via the Android Support Repository. The new runner contains all improvements of GoogleInstrumentationTestRunner and adds more features, such as:

  • JUnit4 support

  • Instrumentation Registry for accessing Instrumentation, Context, and Bundle Arguments

  • Test Filters @SdkSuppress and @RequiresDevice

  • Test timeouts

  • Sharding of tests

  • RunListener support to hook into the test run lifecycle

  • Activity monitoring mechanism - ActivityLifecycleMonitorRegistry

For details, see the AndroidJUnitRunner user guide.

See Also

Publication date: