I have written a spock test where I'm trying to make assertions on a list of items. Let's say as an example I want to check every number in a list if it is equal to 500:
def numbers = [1,2,3,4]
numbers.each{
assert it == 500
}
Returns the following
Assertion failed:
assert it == 500
| |
1 false
How can I make an assertion on a list without stopping at the first failure? Here is the spock test to accompany my assertion:
def "Check if each number in a list is 500"{
given: "A list of numbers"
def numbers = [1,2,3,4]
expect: "each number to be 500"
numbers.each{
assert it == 500
}
To clarify I want to see each failure in my spock test report
So I should see the 1 != 500, 2!= 500, etc.
@Unroll
, I like to include something about each individual test case in the test name, just for documentation purposes if nothing else. So I would probably name the test"Check if #number is 500"
instead of the name you chose. – Conscious