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 skip a node from JSON assertion

Anshu
Anshu Posts: 1

Hi All,

I am having total 15 scenarios in my test and i am using value assertion to check for the correct values in the response but i am facing one problem suppose for first scenario i am having one element in the response and i have added that in my list of assertion bu for the 3rd scenario that element wont come in the response when i am running my test it is getting failed as it is not finding that node in the response traffic.

Is there a way so that i can skip a particular node from the JSON assertion for a particular scenario and for other one it can be ignored?

Comments

  • Thomas Moore
    Thomas Moore Posts: 82 admin

    Hi Anshu,

    The best way I can think of to do this is by using a Conditional Assertion. In my case here, I have a conditional assertion that checks if an element appears in the response with an Occurrence Assertion, and if it does, it then makes the assertion on that value with a Value Assertion.

    I hope this helps!

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    You may also consider using a Diff tool. This is the simplest way to assert on the entire document but also let you configure any specific differences to ignore.