How to fail the test case based on the response code

ParasofttoudayaParasofttoudaya 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??




  • Thomas MooreThomas Moore Posts: 69 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!

  • ParasofttoudayaParasofttoudaya 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 MooreThomas Moore Posts: 69 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.

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    Thanks a lot!!

  • ParasofttoudayaParasofttoudaya 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_parasoftbenken_parasoft Posts: 728 ✭✭✭

    Which version of SOAtest are you using?

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    Version : 9.10

  • benken_parasoftbenken_parasoft Posts: 728 ✭✭✭

    I am not seeing any issue. I setup a REST Client to GET . 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.

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    Sure Thanks for the response.

Sign In or Register to comment.