以下是示例代码:
class MySpec extends spock.lang.Specification {
def "My test"(int b) {
given:
def a = 1
expect:
b > a
where:
b << 2..4
}
}
使用列表而不是范围时会引发以下编译错误:“where-blocks may only contain parameterizations (e.g. 'salary << [1000, 5000, 9000]; salaryk = salary / 1000')”
但如果使用列表而不是范围:
where:
b << [2,3,4]
编译并按预期运行得很好。
我能否通过某种方式指定一个范围?
..
有更高的优先级,我经常因为不能执行1..2.each { println it }
而感到恼火。 - tim_yates1..2.with { it * 2 }
:) - dmahapatro