Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 使用JUnit的Android Studio中的代码覆盖率_Unit Testing_Android Studio_Testing_Junit4 - Fatal编程技术网

Unit testing 使用JUnit的Android Studio中的代码覆盖率

Unit testing 使用JUnit的Android Studio中的代码覆盖率,unit-testing,android-studio,testing,junit4,Unit Testing,Android Studio,Testing,Junit4,我正试图为我在Android Studio中的项目获取代码覆盖率指标 在我的应用程序中,测试包中有一个名为RouterTest的类,它包含很多测试。所有测试都正常运行,正如预期的那样,但当我尝试获取一些代码覆盖率指标时,它表示找不到任何测试 我一直在寻找我的问题的教程和答案,但到目前为止我还没有找到答案 我在build.gradle(模块:app)中有这个 我的RouterTest.class被注释为与JUnit4一起运行,如下所示: @RunWith(AndroidJUnit4.class)

我正试图为我在Android Studio中的项目获取代码覆盖率指标

在我的应用程序中,测试包中有一个名为RouterTest的类,它包含很多测试。所有测试都正常运行,正如预期的那样,但当我尝试获取一些代码覆盖率指标时,它表示找不到任何测试

我一直在寻找我的问题的教程和答案,但到目前为止我还没有找到答案

我在build.gradle(模块:app)中有这个

我的RouterTest.class被注释为与JUnit4一起运行,如下所示:

@RunWith(AndroidJUnit4.class)
public class RouterTest extends ApplicationTestCase<Application> {

    ... Lots of tests

}
@RunWith(AndroidJUnit4.class)
公共类RouterTest扩展了ApplicationTestCase

结果总是令人失望的“没有发现测试”

我错过了什么


感谢您的帮助。

检查测试类上的包名是否与文件的实际位置匹配,尝试使缓存无效(ctrl-a,然后键入“使缓存无效并重新启动”)和/或删除生成配置

@RunWith(AndroidJUnit4.class)
public class RouterTest extends ApplicationTestCase<Application> {

    ... Lots of tests

}