繁体   English   中英

Android Studio空测试套件

[英]Android Studio Empty test suite

我在向我的android应用程序添加测试时遇到问题。 如果我想运行示例测试,则会发生以下错误:

Running tests Test running startedTest running failed: Unable to find instrumentation info for: ComponentInfo{xxx/android.test.InstrumentationTestRunner} Empty test suite.

我的测试课看起来像这样:

public class ExampleTest extends AndroidTestCase {

public void test() throws Exception {
    final int expected = 1;
    final int reality = 5;
    assertEquals(expected, reality);
    }
}

奇怪的是,它在一个仅包含一个模块的不同项目中都能正常工作。 在那个小型测试项目中,项目结构无关紧要。 我尝试了一切。 使用src / androidTest / java / my.package.test的Structure可以很好地将测试类直接放在我的真实资源中。 也无需在运行配置或build.gradle中指定检测运行器。

但是在我的真实项目中,它根本不起作用。 我还能尝试什么?

结果是,我必须更改构建类型才能进行调试。 由于某些莫名其妙的原因,它不适用于自定义生成类型,尽管它适用于我的小型示例项目。

以我为例,我在构造函数中实例化了一个类,该类导致了“空测试套件”。

 public class ApplicationTest extends ApplicationTestCase<Application> { private MyClass mc; public ApplicationTest() { super(Application.class); mc = new MyClass(this.getContext()); } .... } 

暂无
暂无

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

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