如此处所述, @Repeat
现在不支持注释.我怎样才能将spock测试标记为重复n次?
假设我有spock测试:
def "testing somthing"() {
expect:
assert myService.getResult(x) == y
where:
x | y
5 | 7
10 | 12
}
Run Code Online (Sandbox Code Playgroud)
如何将其标记为重复n次?
您可以使用如下@Unroll
注释:
@Unroll("test repeated #i time")
def "test repeated"() {
expect:
println i
where:
i << (1..10)
}
Run Code Online (Sandbox Code Playgroud)
它将为您创建10个独立的测试。
编辑完问题后,请使用EDIT进行编辑:
def "testing somthing"() {
expect:
assert myService.getResult(x) == y
where:
x | y
5 | 7
5 | 7
5 | 7
5 | 7
5 | 7
10 | 12
10 | 12
10 | 12
10 | 12
10 | 12
Run Code Online (Sandbox Code Playgroud)
}
这是目前在spock中执行此操作的唯一方法。