我在 Android Studio 的 Android 项目中设置了测试。我有一个带有测试的单元测试类和一个带有测试的仪器测试类。当我运行 gradlew connectedAndroidTest 时,单元测试运行良好,但仪器测试未运行。
这是我的项目结构
根 - 应用程序 - 来源 - 安卓测试 - java - 包裹名字 - 单元测试类 - InstrumentationTest类
单元测试类扩展了 TestCase。仪器测试类扩展 ActivityInstrumentationTestCase2
仪器测试类中的示例测试是
public void testJSONReturnsString() {
String json = JSON.getJSonFeed(getActivity().getApplicationContext(), "http://foo.bar");
assertNotNull(json);
}
在我的 build.gradle 我有 testInstrumentationRunner "android.test.InstrumentationTestRunner"
在默认配置部分
有谁知道为什么 Instrumentation 测试类无法运行?
最佳答案
最后是因为我的检测类中没有默认构造函数!
关于android - 单元/仪器测试 Android Gradle。仪器测试不会运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22956081/