Spock has great assertion support. But I've got one problem - I wanna add more context data (for example url of the checked page) to assertion info.
I've tried
assert a == b, [context]
but in this case Spock doesn't print a
and b
values
You can either rely on the default condition output, or define a custom message as already explained in another answer (e.g. assert a == b : "my message involving $url"
). Besides you can customize the method name:
@Unroll
def "log in to #theUrl"() {
...
where:
theUrl = ...
}
You would typically use this if you wanted to repeat the same test for different URLs, but you can also use it for a single URL.
Why just not do add a and b into the list after colon?
assert a == b, [a, b, context]
I know this is kind of redundant and message won't be formatted in nice Spock way, but still you can format it with GString in the way suitable for your need.
I don't believe you can. Not sure what your test looks like, but maybe the @Unroll
annotation could help here?
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