简体   繁体   English

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

[英]Unit/Instrumentation tests Android Gradle. Instrumentation tests won't run

I have Tests set up in an Android project in Android Studio. 我在Android Studio的一个Android项目中设置了测试。 I have a Unit test class with tests and an Instrumentation test class with tests. 我有一个带有测试的单元测试课程和一个带有测试的仪器测试课程。 When I run gradlew connectedAndroidTest the unit tests run fine but the instrumentation tests are not run. 当我运行gradlew connectedAndroidTest时,单元测试运行良好,但仪表测试未运行。

Here is my project structure 这是我的项目结构

root - app - src - androidTest - java - packagename - UnitTest class - InstrumentationTest class 根-应用-src-androidTest-java-包名称-UnitTest类-InstrumentationTest类

The unit test class extends TestCase. 单元测试类扩展了TestCase。 The instrumentation test class extends ActivityInstrumentationTestCase2 仪表测试类扩展了ActivityInstrumentationTestCase2

An example test in the instrumentation test class is 仪器测试类中的一个示例测试是

public void testJSONReturnsString() {

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

In my build.gradle I have testInstrumentationRunner "android.test.InstrumentationTestRunner" 在我的build.gradle中,我有testInstrumentationRunner“ android.test.InstrumentationTestRunner”

in the defaultConfig section 在defaultConfig部分中

Does anyone know why the Instrumentation test class wouldn't run? 有谁知道为什么Instrumentation测试类不会运行?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM