android - Android studio 中的空测试套件运行测试并覆盖

标签 android android-studio intellij-idea junit android-testing

我编写了一些测试,并希望使用 IntelliJ 插件获得代码覆盖率! 我的测试代码:

public class TestLogin extends ActivityInstrumentationTestCase2<ActivityAccounting> {

private Solo solo;

public TestLogin() {
    super(ActivityAccounting.class);
}

@Override
public void setUp() throws Exception {
    super.setUp();
    solo = new Solo(this.getInstrumentation(), getActivity());
}

@Test
public void testLoginClick() throws Exception {
    //Some UI test
}
}

EditConfiguration 中,我添加了一个 Junit 测试:

enter image description here

但是当我运行覆盖范围时,我编写了以下错误代码:

enter image description here

我该怎么办? 提前tnx。

最佳答案

如果您在 build.gradle 中配置了所有内容,如下所示:

dependencies {
    testCompile 'junit:junit:4.12'
    compile 'com.jayway.android.robotium:robotium-solo:5.6.0'
    compile 'com.android.support:support-annotations:23.0.0'
    //....
    //....
}

您只需在测试类中单击鼠标右键并选择“运行”即可运行测试

关于android - Android studio 中的空测试套件运行测试并覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38719110/

相关文章:

android - 任何允许访问前置和后置摄像头的 Android 设备?

java - CamcorderProfile.videoCodec 返回错误值

javascript - Phonegap 3.0.0 所有请求 404

java - 查询网页

android - Parcelable readString() 可为空警告

java - 如何将android文件夹中的多个图像转换为单个PDF?

android - 未捕获的翻译错误构建proguard

scala - Intellij 代码样式对齐单行注释

android - Flutter markdown 包依赖项没有为我正确安装

java - 在 Windows 命令行上运行在 IntelliJ 中创建的 Java 程序