单元/仪器测试Android Gradle。仪表测试不会运行

时间:2014-04-09 07:49:41

标签: android testing instrumentation

我在Android Studio的Android项目中设置了测试。我有一个带测试的Unit测试类和一个带测试的Instrumentation测试类。当我运行gradlew connectedAndroidTest时,单元测试运行正常,但是没有运行仪器测试。

这是我的项目结构

根    - 应用程序      - src        - androidTest          - java           - 包裹名字              - UnitTest类              - InstrumentationTest类

单元测试类扩展了TestCase。检测测试类扩展了ActivityInstrumentationTestCase2

检测测试类中的示例测试是

public void testJSONReturnsString() {

    String json = JSON.getJSonFeed(getActivity().getApplicationContext(),     "http://foo.bar");
    assertNotNull(json);
}

在我的build.gradle中,我有     testInstrumentationRunner“android.test.InstrumentationTestRunner”

在defaultConfig部分

有谁知道为什么Instrumentation测试类不能运行?

1 个答案:

答案 0 :(得分:1)

最后是因为我的仪器类中没有默认构造函数!

相关问题