As described here @Repeat
annotation is not supported right now. How can I mark spock test as repeated n times?
Suppose I have spock test:
def "testing somthing"() {
expect:
assert myService.getResult(x) == y
where:
x | y
5 | 7
10 | 12
}
How can I mark it to repeat n times?
You can use @Unroll
annotation like this:
@Unroll("test repeated #i time")
def "test repeated"() {
expect:
println i
where:
i << (1..10)
}
It will create 10 separate tests for you.
EDIT after you've edited your question, use the simplest way to achieve this:
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
}
This is currently only way to do this in spock.
You can use a where-block as shown in the answer above. There is currently no way to repeat a method that already has a where-block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With