Search code examples
apicucumberbddkarate

want to test assertion of integer value should be >3 in Karate API


json response is "Value": 0.23

i want to put assertion here value should be less than 3 so how to do this ? tried some examples in documentation but they are for array format of jsonenter code here

Scenario: Shows the minimum time any DB request to CS will take This value is an important indicator for the performance of the database access.

Given path 'admin/rest/status/db/'
When method get
Then status 200
And match response contains { Value: ">3"}
 * match Value == { '#? _ > 3' }
* match $.Value == '##[_ > 3]'
* def H = response
* print H

tried with above assertion not found any solution


Solution

  • You can construct it as below:

    * def resp = { "Value": 0.23 }
    * match resp == { "Value": '#? _ < 3' }
    * match resp.Value == '#? _ < 3'