Thursday, 13 June 2019

Android Espresso ActivityTest gives 'package android.support.test.rule does not exist'

I am learning TDD for Android using this demo:

https://github.com/NileshJarad/TDD_Demo

I can run all the unit tests and the Mockito tests, but the "activityTests" fail with these errors:

error: package android.support.test.rule does not exist 
error: package android.support.test.espresso does not exist 
error: package android.support.test.espresso.action does not exist  
error: package android.support.test.espresso.action does not exist  
error: package android.support.test.espresso.action does not exist  
error: package android.support.test.espresso.assertion does not exist   
error: package android.support.test.espresso.matcher does not exist 
error: package android.support.test.espresso.matcher does not exist 
error: package android.support.test.espresso.matcher does not exist 
error: cannot find symbol class ActivityTestRule    
error: cannot find symbol method isDisplayed()  
...

The versions are Android 9.0 API 28.

I tried the suggestions at https://www.google.com/search?q=Android+ActivityTest+gives+%27package+android.support.test.rule+does+not+exist%27 but they all refer to app/build.gradle lines that we already have:

...
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
...
dependencies {
...    
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation 'com.android.support.test:testing-support-lib:0.1'
}



from Android Espresso ActivityTest gives 'package android.support.test.rule does not exist'

No comments:

Post a Comment