【问题标题】:Unit/Instrumentation tests Android Gradle. Instrumentation tests won't run单元/仪器测试 Android Gradle。仪器测试不会运行
【发布时间】: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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-02
    相关资源
    最近更新 更多