how to validate if response field is expected to return X and Y.
Hello ,
I want to assert on a a response field(string comparison assert) . But the response field value returns X and Y . Both values are Valid. I want my assertion to pass the test in both cases.
I know we can assert on one expected value.
can you please advise which assertion to use to validate the same field with two expected values.
I am using Parasoft SOA test 9.9
Regards,
Neil.
Comments
-
It sounds like you want to use the "OR Assertion" (XML/JSON Assertor tool). In other words, you create a validation for "X", a second validation for "Y", and then join them with an "OR".
1 -
Here is how it will look like in the JSON Assertor:
0 -
Thank you for your feedback. it's very helpful.
0 -
Hello Andrey,
The OR assertion worked when I assert on item[1]... But when I assert of all fields, it's throwing an error.
I am trying to assert on a fields(category) in response which occurs multiple times in the response.
I want to the test to pass if the value of Category is 'X' or 'Y'.. The assertion should check all the occurrences of Category field in response and pass when it has X or Y.0 -
Hi Neil,
The simplest approach in this case might be to write a custom assertion where you put the "OR" logic into the custom script.1 -
Hello, Can I use JsonSlurper utility?
import groovy.json. JsonSlurperif No, Can you give me an example how to read the response values and assert them with expected results.
0 -
Good morning Neil,
sips coffeeAnother way to complete your scenario is by extracting the repeated element values using a databank and storing them into a writable data source. You could then create a new messaging client containing the writable data to pass the desired values through an OR assertion. Give this a shot
0 -
I have to add messaging client to just validate a fields which is expected to be 'X' or 'Y' in response.
usually to assert http status codes. we can give as below.
200;500
In this case the test will pass if the status code is 200 or 500.anyways I will try what you mentioned above.
0