Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

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

Neil
Neil 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

Regards,
Neil.

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    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 Madan
    Andrey Madan Posts: 388 ✭✭✭

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

  • Neil
    Neil Posts: 38

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

  • Neil
    Neil 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.

  • jakubiak
    jakubiak Posts: 795 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.

  • Neil
    Neil 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.

  • OmarR
    OmarR Posts: 233 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 :)

  • Neil
    Neil 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.
    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.