首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >androidx.test.InstrumentationRegistry已弃用

androidx.test.InstrumentationRegistry已弃用
EN

Stack Overflow用户
提问于 2018-10-22 15:39:51
回答 6查看 24.9K关注 0票数 61

切换到AndroidX并收到弃用的:import androidx.test.InstrumentationRegistry

如果我做了下一个导入:import androidx.test.platform.app.InstrumentationRegistry,我就不能使用getContext()了。

例如:val context = InstrumentationRegistry.getContext()

build.gradle

androidTestImplementation 'androidx.test.ext:junit:1.0.0-beta02'
androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
EN

Stack Overflow用户

发布于 2019-10-11 19:49:53

我花了很多时间在应用程序build.gradle中使用testImplementation而不是androidTestImplementation和reverse来移动依赖项。

我的错误是我在test文件夹而不是androidTest文件夹中创建了测试类,因此得到了AndroidJuit4InstrumentationRegistry的未解决的错误。

当我将我的测试文件转移到androidTest文件夹中,然后在build.gradle中使用androidTestImplementation独立实现测试库的问题得到了解决。

票数 7
EN
查看全部 6 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52924431

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档