Is there a way in karate framework to assert the "status" (which is usually an integer value like 200, 400) through a file or a variable?

Viewed 256

Like in the below test scenario, the request is being read from the json file. Likewise, can the status 200 be read from a file or variable which has been assigned the value=200?

Scenario: CF_001 - When Order is Successfully Created
    Given path '/api/v1.0/abcd/create'
    And header Authorization = 'Bearer ' + accessToken
    And header X-Azure-FDID = XAzureFDID
    And request read('Requests/request01.json')
    When method POST
    **Then status 200**
    Then print response
    And match read('Responses/QAcreate01.txt') == response.status
1 Answers

Can you try to do it using defining a variable:

def expectedStatus = 200
assert responseStatus == expectedStatus

or

And match responseStatus == expectedStatus
Related