Search code examples
androidandroid-testingandroid-espressoandroid-instrumentation

Android instrumentation tests, choice of libraries. Should I use libs:test:testing-support or test:rules or test:runner?


On official website: https://google.github.io/android-testing-support-library/docs/espresso/setup/index.html

they say, that I have to add this:

androidTestCompile 'com.android.support.test:runner:0.5'

but in tutorials I found:

 androidTestCompile 'com.android.support.test:rules:0.3'
 androidTestCompile 'com.android.support.test:testing-support-lib:0.1'

Which libraries do I need?


Solution

  • for my latest project I'm using these androidTest dependencies:

    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.squareup.spoon:spoon-client:1.6.2'
    androidTestCompile "com.android.support:support-annotations:$SUPPORT_VERSION"
    androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
    

    Beware that some tutorials might be really out of date. Notice that I'm using com.android.support.test subLibrary at its latest version 0.5, not 0.3.

    Also, beware that rules and runner are have diferrent contents, so you may use both, but one instead of another

    I'm also pretty sure that Google's tutorial about Espresso is enough and you don't need to use others. Check: https://google.github.io/android-testing-support-library/docs/espresso/

    Hope it will help