Reputation: 181
whenever I attempt to validate a schema or use fuzzy matching to validate a boolean field from a response within a JSON object, it always seems to pass despite inputting incorrect data.
For the sake of the query, let's focus on using in-line fuzzy-matching as supposed to storing the schema in a separate file.
Feature file:
* match response.flags contains any {unitedKingdom: '##boolean'}
Response:
"flags": {
"unitedKingdom": true,
"spain": false,
"india": true,
"japan": true
}
}
The aim of my assertion is to assert that each value returns the correct value type, in whatever order. If the value is not returned for whatever reason or there is more values than what has been defined in the schema, I would like the test to fail. How could I achieve this?
I would assume use contains any
. However, when I attempt to match a random value which is not returned in the response, I receive a successful message. Please see below.
* match response.flags contains any {test: '##boolean'}
- the test passes. I would expect this to fail. Please help me understand why this is passing and what I can do to reach my assertion
aim which is described above.
I am using 0.9.5.RC5.
Upvotes: 1
Views: 2918
Reputation: 58058
Don't use the optional marker:
* def foo = { b: true }
* match foo contains { a: '#boolean' }
You are doing this, which will pass even if it is not present:
* match foo contains { a: '##boolean' }
Upvotes: 1