lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

Set up Android Test

In order to use Android Test, you must modify your app project's classpath dependencies within your development environment, as shown in the following steps:

  1. Open the build.gradle file for your app.
  2. In the repositories section, add Google's Maven repository. To do so, add a maven section with the "https://maven.google.com" endpoint. For example:

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
  3. For each Android Test package you want to use, add its package name to the dependencies section. For example, to add the espresso-core package, add the following lines:

    dependencies {
        ...
        androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
    }

    Caution: Using dynamic dependencies (for example, espresso-core:3.0.0+) can cause unexpected version updates and regression incompatibilities. We recommend that you explicitly specify a particular version number (for example, espresso-core:3.0.0).

List of Android Test dependencies

Android Test includes many dependencies. As discussed in Adding Gradle dependencies from a Maven repository, you can add these dependencies to your development environment by adding each dependency within your module-level build.gradle file.

The following dependencies are available in Android Test:

dependencies {
  // AndroidJUnitRunner and JUnit Rules
  androidTestCompile 'com.android.support.test:runner:1.0.2'
  androidTestCompile 'com.android.support.test:rules:1.0.2'

  // Espresso dependencies
  androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
  androidTestCompile 'com.android.support.test.espresso:espresso-contrib:3.0.2'
  androidTestCompile 'com.android.support.test.espresso:espresso-intents:3.0.2'
  androidTestCompile 'com.android.support.test.espresso:espresso-accessibility:3.0.2'
  androidTestCompile 'com.android.support.test.espresso:espresso-web:3.0.2'
  androidTestCompile 'com.android.support.test.espresso.idling:idling-concurrent:3.0.2'

  // The following Espresso dependency can be either "compile"
  // or "androidTestCompile", depending on your app's implementation
  androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:3.0.2'
}