java - !!!预计 JUnit 版本 3.8 或更高版本

标签 java android junit

我的 Android Studio 项目有一个依赖于 android 框架的 app 模块,我创建了一个名为 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 3.8 或更高版本错误消息。

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

其实我已经尝试过实现这个解决方案,但是问题依然存在。 Image of my dependencies structure

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

最佳答案

我刚才已经解决了这个问题。它可能会帮助你......也许。 一点说明:

  1. 转到运行 -> 编辑配置
  2. 删除左侧面板上的 JUnit 配置

enter image description here

关于java - !!!预计 JUnit 版本 3.8 或更高版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29172698/

相关文章:

java - 从 Java 中的大字符串中查找单词列表及其计数的最佳方法?

Java 包装器 - QUEUELIST_NEED_NATURAL_NEXT

android - 谷歌在 map 上的行车方向与航路点

android - UIView 的 convertRect/convertPoint 函数的 android 等价物是什么?

unit-testing - 如何运行并发单元测试?

java - JBoss 线程模型与 Java 5 任务执行框架

java - 安卓/JAVA : Get current time based on timezone

android - Android 中 fragment 的按钮可见性问题

java - JUnit 使用 h2 数据库测试 flywaydb

java - 无法使用 EasyMock 为内部类编写测试用例