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 fail the test case based on the response code

Parasofttoudaya
Parasofttoudaya Posts: 232 ✭✭

Hi Team,

Would like to fail the based on the response code.
if response code != {204,200,207} then fail.

is there any way i can have assertion on it??

Regards
Udaya

Tagged:

Comments

  • Thomas Moore
    Thomas Moore Posts: 82 admin

    Hi Udaya,

    What kind of messaging clients are you using? If you are using a regular Messaging client or a REST client (the recommended methods for this), you are able to set the accepted HTTP response codes under the Success Criteria tab of the client.

    SOAP clients are a bit different in that they expect 2xx response codes (or whatever code as defined by their service description) or else they will fail. If you wish to do the specific check with a SOAP client, I would recommend extracting the code with a text databank and using an XML Assertor with a custom assertion to check the value.

    Hope this helps!

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    Thanks for immediate response.

    Mine is rest client, I don't use this response code validation for SOAP ...
    is there any way to do 2xx or list of codes for passing the test case ?? (200,207,204)
    I am able to fetch using the Text Databank, to loop thru three i have to use scripting.

    is there any other tool features available??

  • Thomas Moore
    Thomas Moore Posts: 82 admin
    edited September 2017

    If you are using a REST client, then perfect!

    Under the Success Criteria tab, you can put in values like (200, 207, 204) without the parentheses and it will work exactly the way you'd expect. You can also put in ranges like 200-205 and all values in between will be valid as well.

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    Thanks a lot!!

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    @Thomas Moore

    I had set it up my Test Success criteria Response codes as "200,201,204,207". I got 409 as response code and still the test case is passed. is this expected result. ?

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Which version of SOAtest are you using?

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    Version : 9.10
    9.10.0.20161130

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    I am not seeing any issue. I setup a REST Client to GET http://ws1.parasoft.com:8080/examples/servlets/ResponseCode/409 . This results in the quality task "Received HTTP Response Code 409: Conflict" which is expected. This happens as expected if I leave "Valid HTTP Response Codes" blank or put "200,201,204,207" or anything else that doesn't match 409. If I put "409" in there then the REST Client passes as expected.

    Parasofttoudaya, I'd recommend contacting Parasoft Support.

  • Parasofttoudaya
    Parasofttoudaya Posts: 232 ✭✭

    Sure Thanks for the response.