!!!预期的 JUnit 版本 3.8 或更高版本
我的Android工作室项目有一个依赖于Android框架的应用程序模块,我创建了一个名为domain的新模块,它只包含纯java类和一些测试类。
在本模块的 build.gradle 文件中,我添加了 junit 和 mockito 库以进行测试,如下所示:
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies {
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:1.9.5'
compile project(':common')
compile project(':model')
//test dependencies
}
但是每当我尝试执行测试类时,Android Studio都会给我错误消息。!!! JUnit version 3.8 or later expected
此问题的所有建议解决方案是打开“项目结构”|模块|依赖关系,并将 junit-4.7.jar上移,使其在类路径中位于 Android 1.6 Platform 之前。
实际上,我已经尝试实现此解决方案,但问题仍然存在。
关于如何解决此问题的任何想法?