无法将JUnit添加到测试和androidTest [英] Can't add JUnit to test and androidTest

查看:143
本文介绍了无法将JUnit添加到测试和androidTest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个测试文件夹中都需要JUnit.所以我加了

I need JUnit in both test folders. So I added

androidTestCompile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'

但是,一旦我将JUnit添加到androidTest中,由于此日志中引发的错误,我就无法运行测试.

But as soon as I add JUnit to the androidTest I cannot run the tests, because of the error thrownin this log.

关于如何解决此问题的任何想法?

Any ideas on how to fix this problem?

我从运行配置中删除了gradle-aware版本.现在它说我的TestSuite为空,但是有一些用@Test

I removed the gradle-aware build from the run configuration. Now it says that my TestSuite is empty, but there are tests annotated with @Test

推荐答案

在您的build.gradle文件中尝试一下

Hava a try with this in your build.gradle file

dependencies {   

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    testCompile 'junit:junit:4.12'

}

这篇关于无法将JUnit添加到测试和androidTest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆