Reputation: 9159
I have something that looks like the similar specification:
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
}
However, at runtime, I get: groovy.lang.MissingMethodException: No signature of method doFlow() is applicable for arguments Something, Record values: [given values]
.
Upvotes: 3
Views: 1528
Reputation: 123890
Both "my flow" and "doFlow" are feature methods as they have blocks such as given
, when
, and then
. It's Spock's responsibility to invoke feature methods, and one feature method cannot call another one. If doFlow
is meant to be a helper method, it should use explicit assert
statements, and shouldn't have any blocks.
PS: Feature methods can't declare method parameters unless they are data-driven (i.e. have a where
block).
PPS: A feature method can't just have a given
/and
block. (You'll get a compile error for this.)
Upvotes: 6