Cannot resolve symbol InstantTaskExecutorRule

纵饮孤独 提交于 2019-11-30 17:25:20

Replace testImplementation by androidTestImplementation. So the tests on folder androidTest can have access to the library.

dependencies {
    androidTestImplementation "android.arch.core:core-testing:1.1.1"
}

I know it's late but I would like to add one thing for this accepted answer, If you want to use,

@Rule
public InstantTaskExecutorRule instantTaskExecutorRule = 
new InstantTaskExecutorRule();

in your JUnit test case, i.e., in test folder then use following dependency, i.e, with testImplementation

dependencies {
testImplementation "android.arch.core:core-testing:1.0.0"
}

If you want to use InstantTaskExecutorRule for your UI or integration test cases, use androidTestImplementation. that is:

androidTestImplementation "android.arch.core:core-testing:1.0.0"

And if you want to add for both, use androidTestImplementation & testImplementation that is:

androidTestImplementation "android.arch.core:core-testing:1.0.0"

testImplementation "android.arch.core:core-testing:1.0.0"

for androidX migration, add

androidTestImplementation "androidx.arch.core:core-testing:2.0.0"

Please put this two dependencies in your gradle file,

dependencies {

    // Test helpers for LiveData
    testImplementation "android.arch.core:core-testing:1.0.0"

    // Test helpers for Room
    testImplementation "android.arch.persistence.room:testing:1.0.0"
}

Further information please go through this link, Android Architecture components integration guide

I think that there is a conflict in some of the linked libraries. I got around this, I used blockingGet() and blockingFirst().

and, in the end, I used https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator

androidTestUtil 'com.android.support.test:orchestrator:1.0.1'

this is what you need!

Sometimes test dependency issues can be an issue of selecting the appropriate build variant, depending on your Gradle configuration. In my case, tests are configured for the debug build variant only.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!