我有一些类似于类似规范的东西:
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]。
发布于 2013-11-12 15:07:08
"doFlow“和”doFlow“都是特性方法,因为它们都有诸如given、when和then等块。调用功能方法是Spock的责任,一个特性方法不能调用另一个特性方法。如果doFlow是一个助手方法,它应该使用显式的assert语句,并且不应该有任何块。
特性方法不能声明方法参数,除非它们是数据驱动的(即有一个where块)。
PPS:一个特性方法不能只是一个given/and块。(这将导致编译错误。)
https://stackoverflow.com/questions/19930573
复制相似问题