Issue
Switched to AndroidX and received deprecated: import androidx.test.InstrumentationRegistry.
If I made next import: import androidx.test.platform.app.InstrumentationRegistry
I can't use getContext().
Ex:
val context = InstrumentationRegistry.getContext().
In build.gradle:
androidTestImplementation 'androidx.test.ext:junit:1.0.0-beta02'
androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
Solution
You can use InstrumentationRegistry.getInstrumentation().getTargetContext() in the most cases from androidx.test.platform.app.InstrumentationRegistry.
If you need the Application, you can use ApplicationProvider.getApplicationContext<MyAppClass>().
If you haven't already, I think you can also use the new test dependency:
androidTestImplementation 'androidx.test:core:1.0.0-beta02'.
Answered By - karuto
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.