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.

JSON Assertion Handling

Hi, I have added an assertion to Virtual Service and when i deployed and ran a test could notice that Assertion is failing but Virtual Service is responding with a proper response instead of an error response saying Assertion failed. Could someone please help me with this issue, i have gone through the user manual and i tried to figure it out but could solve the issue.

Tagged:

Comments

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,
    Assertions on virtual services are not expected to affect the response. What is that you want to accomplish with the assertion? Are you trying to make sure that a request is valid in some way before responding?

  • Hi William,

    Fro your Question, Are you trying to make sure that a request is valid in some way before responding? - Yes i want to check if the request is valid or not.

    I want to make sure that if request is not coming with a valid data i wanted the Virtual Service to give a failed response. Using Response Correlation i have tried this option and its working. I feel Virtual Service should response back if any Assertion fails.

    What is the use of sending a proper response if some condition fails in Virtual Service. Sorry if i am Harsh.

    If you have seen Real APIs, they will send an error response if validation fails on Request Parameters or Body

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,

    Chained tools do not directly affect the response. When a responder correlates then it is expected that it will send back the proper response. For the case of wanting to send back a different message if validation fails there are a number of ways to accomplish it but just chaining the assertion tool is not enough.

  • Hi William, I have worked on CA DevTest tool and this tool has an option of how the Virtual Service to behave when an assertion fails. If Parasoft has this option it will be great. Thanks for your responses.

  • OmarR
    OmarR Posts: 233 admin

    Good morning,

    One approach would be to have a "catch all" responder at the end of your suite. This responder could pick up any messages that failed to satisfy a condition/assertion before it. For example:

    Can you give us an example of the type of assertion you're trying to apply?