首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >史波克MissingMethodException

史波克MissingMethodException
EN

Stack Overflow用户
提问于 2013-11-12 13:32:29
回答 1查看 1.4K关注 0票数 3

我有一些类似于类似规范的东西:

代码语言:javascript
复制
def "my spec"(Record record) {
    given: 
        Something something = getSomething()
    and: 
        otherThing = getOtherThing()

    doFlow(something, record)
    if (record.someType = Types.SOME_SPECIFIC_TYPE) {
        doFlow(something, record)
    } 
}

def doFlow(Something something, Record record) {
    when:
         //code
    then:
         //asserts

    when:
         //code
    and: 
         //mode code
    then:
         //code
}

但是,在运行时,我得到:groovy.lang.MissingMethodException: No signature of method doFlow() is applicable for arguments Something, Record values: [given values]

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-12 15:07:08

"doFlow“和”doFlow“都是特性方法,因为它们都有诸如givenwhenthen等块。调用功能方法是Spock的责任,一个特性方法不能调用另一个特性方法。如果doFlow是一个助手方法,它应该使用显式的assert语句,并且不应该有任何块。

特性方法不能声明方法参数,除非它们是数据驱动的(即有一个where块)。

PPS:一个特性方法不能只是一个given/and块。(这将导致编译错误。)

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19930573

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档