简体   繁体   中英

Espresso not finding test apk

Im building a test suite for my app, but keep getting the following error when trying to run a test on an emulator:

$ adb push /Users/me/dev/Android/app/build/outputs/apk/debug/app-debug.apk /data/local/tmp/myApp.debug

$ adb shell pm install -t -r "/data/local/tmp/myApp.debug" pkg: /data/local/tmp/myApp.debug Success

The APK file /Users/me/dev/Android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk does not exist on disk. Error while Installing APK

The real debug file i want the tests to run against is located at:

/Users/me/dev/Android/app/build/outputs/apk/debug/app-debug.apk

I have the following setup in gradle:

    android.defaultConfig {
       testInstrumentationRunner 
    'android.support.test.runner.AndroidJUnitRunner'
    }

    ...
    dependencies {
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:runner:1.0.1'
    androidTestCompile 'com.android.support.test:rules:1.0.1'

    // Espresso support
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    // add this for intent mocking support
    androidTestCompile 'com.android.support.test.espresso:espresso-intents:3.0.1'
    }

Any idea how i can configure the test runner to look for the debug apk in the correct directory?

Thanks in advance :)

UPDATE - Things i have tried already are:

  1. ./gradlew connecteAndroidTest
  2. ./gradlew assembleDebug
  3. ./gradlew assembleDebugAndroidTest
  4. Creating a new test runner from Edit Configuration

经过大量阅读后,我确定这不是可以配置的东西,并且对于Android Studio来说有些古怪,使缓存无效并重新开始修复它:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM