I am attempting to follow the Android ActivityScenario
documentation to write Robolectric-based tests. Adding androidTestImplementation "androidx.test.core:app:1.2.0"
to my build.gradle
allows me to add import androidx.test.core.app.ActivityScenario;
to my test class and use the ActivityScenario
class. Despite this, gradle is reporting Failed to resolve: androidx.test.core:app:1.2.0
which means I can't run the tests.
I have tried cleaning the build, re-running the gradle sync, invalidating caches and restarting. I have also tried importing other packages from https://mvnrepository.com/artifact/androidx.test, none of which result in ActivityScenario
being found. In particular, I would expect androidTestImplementation "androidx.test:core:1.2.0"
to work but it does not.
Versions:
- Android Studio 3.5
- Robolectric 4.3.1
I just realized that because I am trying to write Robolectric tests which are not instrumented, I need to use
testImplementation
rather thanandroidTestImplementation
.Adding
testImplementation "androidx.test:core:1.2.0"
to mybuild.gradle
works as expected.How very strange that
androidTestImplementation "androidx.test.core:app:1.2.0"
somehow tricked Android Studio into resolving the class.