Android studio中的空测试套件使用覆盖率运行测试
我写了一些测试,希望通过IntelliJ插件获得代码覆盖率! 我的测试代码:Android studio中的空测试套件使用覆盖率运行测试,android,android-studio,intellij-idea,junit,android-testing,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
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
}
}
公共类TestLogin扩展了ActivityInstrumentationTestCase2
但当我在覆盖范围内运行时,我会编写以下错误代码:
我该怎么办?
提前使用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'
//....
//....
}
您只需在测试类中单击鼠标右键并选择“运行”即可运行测试。我之前添加了此依赖项,而且我的测试运行良好,但我无法获得测试代码覆盖率!你知道吗?你是以JUnit测试的方式运行它吗?是的。我添加了一个junit测试,如EditConfiguration中问题所示,名为“Unnamed”,并运行此junit测试。不使用此单元测试,而是按照我作为答案输入的最后一个步骤进行操作。检查此链接,最后一个问题