Android Test Orchestrator not working with Android X

前端 未结 3 543
不思量自难忘°
不思量自难忘° 2021-02-13 09:21

I have recently migrated my project to use AndroidX, and have configured test orchestrator for my espresso tests on gradle using the following docs:

https://developer.an

相关标签:
3条回答
  • 2021-02-13 09:37

    For anyone else struggling with the Cannot convert string value 'ANDROIDX_TEST_ORCHESTRATOR' to an enum value of type 'com.android.builder.model.TestOptions$Execution' (valid case insensitive values: HOST, ANDROID_TEST_ORCHESTRATOR) error message, ANDROIDX_TEST_ORCHESTRATOR seems to be incompatible with the latest version of IntelliJ (2018.3.5), it worked fine in Android Studio (3.3.2).

    0 讨论(0)
  • 2021-02-13 09:38

    Anyone with Complex projects - here are my gradle changes

    repositories {
    mavenCentral()
    flatDir {
        dirs 'aars'
    }
    maven {
        url "https://maven.google.com"
    }
    google()}
    


    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    


    dependencies {
    compile 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    compile 'androidx.core:core:1.0.0'
    compile 'androidx.recyclerview:recyclerview:1.0.0'
    compile 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.0'
    //kapt 'androidx.databinding:databinding-compiler:1.0.0'
    androidTestImplementation('androidx.test:runner:1.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation('androidx.test:rules:1.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestUtil 'androidx.test:orchestrator:1.1.0'
    implementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
    // Espresso support
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation('androidx.test.espresso:espresso-intents:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation('androidx.test.espresso:espresso-web:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile('androidx.room:room-runtime:2.0.0', {
        exclude group: 'com.android.support'
    })
    kapt 'androidx.room:room-compiler:2.0.0'
    compile('androidx.room:room-rxjava2:2.0.0', {
        exclude group: 'com.android.support'
    })
    testCompile('androidx.room:room-testing:2.0.0', {
        exclude group: 'com.google.code.gson'
    })
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    compile 'androidx.exifinterface:exifinterface:1.0.0'}
    


           classpath 'com.android.tools.build:gradle:3.4.1'
    

    rest of the errors I had to fix manually but in the end it worked

    0 讨论(0)
  • 2021-02-13 09:47

    Purely by guessing, I changed the following in my gradle config

    from:

      testOptions {
        execution 'ANDROID_TEST_ORCHESTRATOR'
      }
    

    to

      testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
      }
    

    and all seems to work.

    0 讨论(0)
提交回复
热议问题