【发布时间】:2014-05-22 06:33:41
【问题描述】:
我在 Android Studio 的一个 Android 项目中设置了测试。我有一个带有测试的单元测试类和一个带有测试的 Instrumentation 测试类。当我运行 gradlew connectedAndroidTest 时,单元测试运行良好,但仪器测试没有运行。
这是我的项目结构
根 - 应用程序 - 源代码 - 安卓测试 - 爪哇 - 包裹名字 - 单元测试类 - InstrumentationTest 类
单元测试类扩展了TestCase。仪器测试类扩展了 ActivityInstrumentationTestCase2
仪器测试类中的一个示例测试是
public void testJSONReturnsString() {
String json = JSON.getJSonFeed(getActivity().getApplicationContext(), "http://foo.bar");
assertNotNull(json);
}
在我的 build.gradle 我有 testInstrumentationRunner "android.test.InstrumentationTestRunner"
在默认配置部分
有人知道 Instrumentation 测试类为什么不运行吗?
【问题讨论】:
-
如果从
build.gradle中删除testInstrumentationRunner部分会怎样?您还可以以my app on github 为例,我同时使用单元测试和仪器测试。另外,我正在使用gradlew connectedCheck。 -
谢谢老兄,会检查这个!
标签: android testing instrumentation