1

I have to mark the test case as passed and failed using an API on the basis of the responseCode

If response code is 200 I will mark it as pass else if it is not 200 (any other code 400, 401, 405, 204 etc ) I have to mark it as failed.

The first condition is working fine where it is == 200. Now when I intentionally fail the API by changing method to get then API returns 405 Method not Allowed. In this case I am expecting it will go in !=200 condition but it is not doing that.

@test1
  Scenario: create new users 
    And path 'users'
    And request requestBody
    When method post
    Then status 200
    * if (responseStatus == 200) karate.call('classpath:util/status.feature@testexecution', { value : '123' })
    * if (responseStatus != 200) karate.call('classpath:util/status.feature@testexecution', { value : 'xyz' })

Maddy
  • 674
  • 1
  • 7
  • 26
  • please assume this is not supported. also I strongly advise you not to write such "generic" tests, and please read this carefully: https://stackoverflow.com/a/54126724/143475 - finally please see this for other ideas: https://twitter.com/KarateDSL/status/1364433453412851714 – Peter Thomas Sep 15 '21 at 12:35
  • also read this: https://stackoverflow.com/a/50350442/143475 – Peter Thomas Sep 15 '21 at 12:37

0 Answers0