一、build.gradle 中配置问题
在defaultConfig中添加
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
在de'pen'd'encies中添加
androidTestCompile ('com.android.support.test:runner:0.5') androidTestCompile 'com.android.support.test:rules:0.5' androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2')
需要更新Android Support Repository 到最新,否则出错,详见https://google.github.io/android-testing-support-library/docs/espresso/setup/
不需要单独引入junit的依赖,应该是这几个包中,哪个包含了junit.
如果同时在引入junit包,编译时,可能出现multidevix XXX 的问题,就是包冲突了。
二、运行case的时候,如果没有执行case,提示:Test running failed: Unable to find instrumentation info for: ComponentInfo{com.umeng.message.example.test/android.test.InstrumentationTestRunner} Empty test suite.
可能的原因
1.在build.gradle 中,defaultConfig下,没有配置如下语句
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2、在Run/Debug Configuration中,Specific instrumentation runner(optial) 中,添加了配置,且不是
android.support.test.runner.AndroidJUnitRunner