how to validate if response field is expected to return X and Y.

NeilNeil Posts: 38

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



  • benken_parasoftbenken_parasoft Posts: 1,025 ✭✭✭
    edited March 2017

    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".

  • Andrey MadanAndrey Madan Posts: 386 ✭✭✭

    Here is how it will look like in the JSON Assertor:

  • NeilNeil Posts: 38

    Thank you for your feedback. it's very helpful.

  • NeilNeil Posts: 38

    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.

  • jakubiakjakubiak Posts: 746 admin

    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.

  • NeilNeil Posts: 38

    Hello, Can I use JsonSlurper utility?
    import groovy.json. JsonSlurper

    if No, Can you give me an example how to read the response values and assert them with expected results.

  • OmarROmarR Posts: 231 admin
    edited May 2017

    Good morning Neil,
    sips coffee

    Another 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 :)

  • NeilNeil Posts: 38

    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.
    In this case the test will pass if the status code is 200 or 500.

    anyways I will try what you mentioned above.

Sign In or Register to comment.