Can't add JUnit to test and androidTest

2019-07-31 05:08发布

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条回答
成全新的幸福
2楼-- · 2019-07-31 05:38

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'

}
查看更多
登录 后发表回答