无法解析符号InstantTaskExecutorRule [英] Cannot resolve symbol InstantTaskExecutorRule
问题描述
我打开示例代码BasicRxJavaSample(来自本文 Room + RxJava ) 最主要的是:
I open example code BasicRxJavaSample (from this article Room+RxJava) The main thing is there:
@Rule
public InstantTaskExecutorRule instantTaskExecutorRule =
new InstantTaskExecutorRule();
BasicRxJavaSample没问题. 但是我不能在测试中应用它. 这就是发生的事情:
And BasicRxJavaSample is all ok. But I can not apply this in my test. That's what's going on:
无法解析符号InstantTaskExecutorRule
Cannot resolve symbol InstantTaskExecutorRule
手动导入无效:
我的自动完成功能是这样的
My autocompletion works like this
但应该是
我的应用程序build.gradle(此处完全掠过):
My app build.gradle (full gradle here):
// tests
testImplementation 'junit:junit:4.12'
androidTestCompile "com.android.support:support-annotations:$supportVersion"
testImplementation "android.arch.core:core-testing:$archVersion"
// Test helpers for Room
testImplementation "android.arch.persistence.room:testing:1.0.0"
// https://github.com/mockito/mockito
testImplementation 'org.mockito:mockito-core:2.13.0'
androidTestImplementation 'org.mockito:mockito-android:2.13.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
// https://developer.android.com/topic/libraries/testing-support-library/packages.html
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:3.0.1'
推荐答案
用androidTestImplementation代替testImplementation.因此,对androidTest文件夹的测试可以访问该库.
Replace testImplementation by androidTestImplementation. So the tests on folder androidTest can have access to the library.
dependencies {
androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
}
如果您未使用 androidx ,请使用
android.arch.core:core-testing:1.1.1
这篇关于无法解析符号InstantTaskExecutorRule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!