Junit 4无法识别测试

Trocchietto

我克隆了一个存储库并尝试运行测试。不幸的是,JUnit 4无法识别我手动添加的目录

在尝试加载测试后,测试GUI会说:

找不到测试。

测试完成。

空的测试套件。

这是我的目录ExampleUnitTest,我通过另一个项目复制了该目录(这是一个默认文件,没有问题,这是行不通的)

在此处输入图片说明

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        testApplicationId "com.commonsware.android.retrofit.test"
    }
}

dependencies {
    compile 'com.squareup.retrofit:retrofit:1.6.1'
    compile 'de.greenrobot:eventbus:2.2.1'
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:rules:0.4.1'
}

在此按要求编辑ExampleUnitTest和运行/调试配置的内容。

package com.commonsware.android.retrofit;

/**
 * To work on unit tests, switch the Test Artifact in the Build Variants view.
 */
public class ExampleUnitTest {
    @Test
    public void addition_isCorrect() throws Exception {
        assertEquals(4, 2 + 2);
    }
}

运行/调试配置 在此处输入图片说明

我会是Jasek

首先,请确保Android Studio在“运行/调试配置”菜单中看不到任何测试为此,请单击Edit Configurations...选项,然后检查左侧的“ JUnit”部分。

在此处输入图片说明

如果没有测试,请单击在此处输入图片说明,选择JUnit,然后选择app模块和ExampleUnitTest类。不要忘记应用更改,然后尝试再次运行测试。

在此处输入图片说明

如果这样做没有帮助,请尝试从Release转换为Debug构建变​​体,并确保Android Monitor选项卡中没有异常的堆栈跟踪。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章