我正在编写下面的代码,它向我显示错误 at ActivityTestRule
它显示 找不到要执行的声明,它不是内置在 Espresso 中吗
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
MainActivity.class);
最佳答案
它是 Espresso 的一部分,但请检查您是否在 build.gradle 中添加了 Espresso
加上 android 测试支持库并同步了 gradle
。
androidTestCompile'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1')
关于android - 使用 Espresso 进行 UI 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35570011/