intellij-idea - MissingMethodException:没有方法签名:org.spockframework.mock.runtime.InteractionBuilder.setArgListKind()
问题描述
我在任何地方都找不到描述的这个问题,所以我为其他发现这个问题的人发帖。
我发现使用 '>>' 或 '>>>' 运行 spock 存根的任何示例都失败,并出现相同的异常。
MissingMethodException: No signature of method: org.spockframework.mock.runtime.InteractionBuilder.setArgListKind() is applicable for argument types: (Boolean, Boolean) values: [true, false]
例如,来自Javitar:Spock 测试 – Spock 教程
def "should return Role.USER when asked for role"() {
given:
List list = Stub()
list.size() >> 3
expect:
// let's see if this works
list.size() == 3
}
解决方案
我正在运行:spockVersion=1.3-groovy-2.5
Intellij 使用 Junit 模板运行 Spock 测试。我在这里找到了解决方案: 结合 Spock 1.2 和 Junit 5 测试 解决方案是将以下内容添加到我的 build.gradle 中:
dependencies {
implementation "org.junit.jupiter:junit-jupiter-api:5.6.1"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.6.1"
}
test { // only needed if doing 'gradle test'
useJUnitPlatform()
}
我在 Intellij/Idea 2019.3 中运行此代码,使用
------------------------------------------------------------
Gradle 6.2.2
------------------------------------------------------------
Build time: 2020-03-04 08:49:31 UTC
Revision: 7d0bf6dcb46c143bcc3b7a0fa40a8e5ca28e5856
Kotlin: 1.3.61
Groovy: 2.5.8
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_152 (Azul Systems, Inc. 25.152-b16)
OS: Linux 4.15.0-52-generic amd64
Linux Mint 19 Tara
推荐阅读
- node.js - internal/modules/cjs/loader.js:892 - Node.js npm 版本检查出错
- algorithm - 制作“老虎机”算法
- java - JavaFX 3D透视相机运动
- android - 后台任务中配置更改时再次重新加载 Json 数据
- computation-theory - DFA 语言和状态图
- firebase - Phoneauthprovider 不是一个函数 firebase react-native
- javascript - 如何在node.js中本地更新发布时间
- c++ - 使用 PuTTY 连接到 winsock 服务器时出现错误“收到的数据包上的填充长度无效”
- salesforce - 我想显示一个帐户的联系人
- curl - 詹金斯所有构建参数(键和值)连接为单个字符串