!!!预计 JUnit 3.8 或更高版本 [英] !!! JUnit version 3.8 or later expected

查看:27
本文介绍了!!!预计 JUnit 3.8 或更高版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Android Studio 项目有一个依赖于 android 框架的应用程序模块,我创建了一个名为 domain 的新模块,它只包含纯 Java 类和一些测试类.

My Android studio project has an app module which is android framework dependent, I have created a new module called domain and it contains only pure java classes and a few test classes.

在这个模块的 build.gradle 文件中,我添加了 junit 和 mockito 库用于测试目的,如下所示:

In this module's build.gradle file, I have added junit and mockito libraries for testing purpose as follows:

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 3.8 版或更高版本都会出现错误消息.

But Android Studio is giving me !!! JUnit version 3.8 or later expected error message whenever I try to execute the test class.

这个问题的所有建议解决方案是打开项目结构|模块 |依赖项,并将 junit-4.7.jar 上移,使其在类路径中位于 Android 1.6 Platform 之前.

All the suggested solutions to this problem is to open the Project Structure | Modules | Dependencies, and move the junit-4.7.jar up, so that it comes before Android 1.6 Platform in the classpath.

其实我已经尝试过实现这个解决方案,但是问题依然存在.

In fact, I have tried to implement this solution but the problem still exists.

知道如何解决这个问题吗?

Any idea on how to resolve this issue?

推荐答案

我设法通过在 .iml 文件中更改以下内容来解决问题

I managed to solve the problem by by changing the following in .iml file

来自:

 <component name="NewModuleRootManager" inherit-compiler-output="true">

到:

  <orderEntry type="inheritedJdk" />

这篇关于!!!预计 JUnit 3.8 或更高版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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