Reputation: 2836
In Spock when I run:
@Unroll
def "max of #a and #b gives #c"() {
expect:
Math.max(a, b) == c
where:
[a, b, c] << [
[1, 0, 1],
[2, 2, 2],
[4, 5, 5]
]
}
My tests pass. However when I try to extract the table into a static method and call the method in the where clause:
@Unroll
def "max of #a and #b gives #c"() {
expect:
Math.max(a, b) == c
where:
[a, b, c] << dataTable()
}
static def dataTable() {
return [
[1, 0, 1],
[2, 2, 2],
[4, 5, 5]
]
}
I get an error:
org.junit.platform.commons.JUnitException: TestEngine with ID 'spock' failed to discover tests
Caused by: org.junit.platform.commons.JUnitException: MethodSelector [className = 'specs.filters.FiltersPostSpec', methodName = 'max of #a and #b gives #c', methodParameterTypes = ''] resolution failed
Caused by: java.lang.VerifyError: (class: specs/filters/FiltersPostSpec, method: $spock_feature_2_3prov0 signature: ()Ljava/lang/Object;) Illegal target of jump or branch
My versions are as follows:
<groovy.version>3.0.9</groovy.version>
<spock-core.version>2.1-groovy-3.0</spock-core.version>
<spock-reports.version>2.3.0-groovy-3.0</spock-reports.version>
Any ideas
A
Upvotes: 0
Views: 257
Reputation: 26
After reading Leonard answer, i decided to play around with this. Changing groovy to 4.0.5 fixed the problem.
Upvotes: 1