everyItem(equalTo()) passes on empty array
danbravo opened this issue · comments
The CoreMatchers everyItem(equalTo("value1"))
doesn't fail if response body is empty array.
For example:
getRequest().then().body("p1", everyItem(equalTo("value1")))
passes for body:
[
{
"p1": "value1",
"parameters": {
"p2": "value2"
},
"p3": true,
"p4": []
},
{
"p1": "value1",
"parameters": {
"p2": "value2"
},
"p3": true,
"p4": []
}
]
but same request also passes for body with empty array:
[]
Using Hamcrest 2.1 and Java 8
Is body a method or framework you have created yourself? Do you have a test case using standard java classes?
The current implement is worked as intended. There is an explicit test for this case. I believe the logic is that if there's nothing in the test in the collection, then there's nothing to fail.