授予WRITE_EXTERNAL_STORAGE后,Espresso测试变得越来越慢

时间:2019-07-04 10:27:57

标签: kotlin junit4 android-espresso

如果我授予我的应用程序的WRITE_EXTERNAL_STORAGE,它将变得太慢,以至于我无法运行Espresso测试。 每个动作要花费5秒钟以上。

我的gradle依赖项是这样的:

androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test:rules:1.2.0'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0')
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
    androidTestImplementation 'com.squareup.spoon:spoon-client:1.3.1'

    implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "androidx.appcompat:appcompat:1.0.2"
    testImplementation 'junit:junit:4.12'
    kapt "android.arch.lifecycle:compiler:${archLifecycleVersion}"
    implementation "com.github.bumptech.glide:glide:${glideVersion}"
    kapt "com.github.bumptech.glide:compiler:${glideVersion}"

    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
    debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'

如果我删除该应用程序并重新运行测试,它会变得非常快,但是由于没有权限,所有测试都会失败。

如果我通过触摸对话框的“确定”按钮或在如下测试代码中手动授予权限,则没关系:

    @get:Rule
    val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
        android.Manifest.permission.WRITE_EXTERNAL_STORAGE
    )

遇到相同问题或知道什么是问题的人吗?

0 个答案:

没有答案