I'm having difficulties in understanding the @Unroll
annotation of Spock's testing framework. In the docs, it is mentioned
Indicates that iterations of a data-driven feature should be made visible as separate features to the outside world (IDEs, reports, etc.)
Still makes not much sense to me. Could someone explain in layman's terms?
@Unroll
is to have each data driven iterations reported independently, as indicated in Spock's website.
I want to add for some more information on using @Unroll
.
If you are using @Unroll
please also customize your test name, it will help you with your reports, example:
@Unroll
def "maximum of #a and #b is #c"() { ... }
When using the @Unroll
each data driven iteration will be counted as a "test" that means that your test count will increase.
Use @Unroll
if you have data driven tests.
Awesome description is at the Spock's website. I should have looked at it in the first place (second place actually, after doc). The main feature is, in case of a failure, the reporting will indicate with what exactly test data it failed, leaving aside the other cases.
an alternation in reporting
the output will look something like
maximum of two numbers[0] PASSED
maximum of two numbers[1] FAILED
Math.max(a, b) == c
| | | | |
| 7 0 | 7
42 false
maximum of two numbers[2] PASSED
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