Cannot resolve symbol InstantTaskExecutorRule

前端 未结 6 1140
一整个雨季
一整个雨季 2020-12-30 18:44

I open example code BasicRxJavaSample (from this article Room+RxJava) The main thing is there:

@Rule
public InstantTaskExecutorRule instantTaskExecutorRule          


        
6条回答
  •  攒了一身酷
    2020-12-30 19:28

    I know it's late but I would like to add one thing to 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(androidTest folder), 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 Android-X use below dependency:

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

    OR

    testImplementation 'androidx.arch.core:core-testing:2.0.0'

提交回复
热议问题