How to fail the test case based on the response code

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 MooreThomas Moore Posts: 45 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!

  • 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: 45 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.

  • Thanks a lot!!

  • ParasofttoudayaParasofttoudaya Posts: 166

    @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: 348 ✭✭✭

    Which version of SOAtest are you using?

  • ParasofttoudayaParasofttoudaya Posts: 166

    Version : 9.10
    9.10.0.20161130

  • benken_parasoftbenken_parasoft Posts: 348 ✭✭✭

    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.

  • ParasofttoudayaParasofttoudaya Posts: 166

    Sure Thanks for the response.

Sign In or Register to comment.