看来您使用的是旧的依赖Espresso 2.2.2
。对于当前版本(Espresso 3.0.2
),ActivityTestRule
依赖关系位于
androidTestImplementation 'com.android.support.test:rules:1.0.2'
检查官方文档,确保其余依赖项也都正确设置,可能是一个好主意,但是我建议您从这里开始使用Espresso。
在的dependencies
部分中app/build.gradle
,添加以下内容:
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
在的defaultConfig
部分中app/build.gradle
,添加以下内容:
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
如果您遇到其他类似的问题,则文档中还包含一长串其他gradle依赖项,它们可能满足您的需要,但是上面列出的内容足以使您入门。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句