【问题标题】:MissingMethodException: No signature of method: org.spockframework.mock.runtime.InteractionBuilder.setArgListKind()MissingMethodException:没有方法签名:org.spockframework.mock.runtime.InteractionBuilder.setArgListKind()
【发布时间】:2026-01-29 04:45:01
【问题描述】:

我在任何地方都找不到该问题的描述,因此我为其他发现此问题的人发帖。

我发现使用 '>>' 或 '>>>' 运行任何 spock 存根示例都会失败,并出现相同的异常。 MissingMethodException: No signature of method: org.spockframework.mock.runtime.InteractionBuilder.setArgListKind() is applicable for argument types: (Boolean, Boolean) values: [true, false]

例如,来自Javitar: Spock Testing – Spock tutorial

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
    }

【问题讨论】:

    标签: intellij-idea mocking spock stubbing


    【解决方案1】:

    我正在运行:spockVersion=1.3-groovy-2.5

    Intellij 使用 Junit 模板运行 Spock 测试。我在这里找到了解决方案: Combining Spock 1.2 and Junit 5 tests 解决方案是将以下内容添加到我的 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
    

    【讨论】:

      最近更新 更多