Can't add JUnit to test and androidTest

a 夏天 提交于 2019-12-24 09:59:52

问题


I need JUnit in both test folders. So I added

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

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?

EDIT: 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


回答1:


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'

}


来源:https://stackoverflow.com/questions/43582318/cant-add-junit-to-test-and-androidtest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!