1

i tried simple validation of part of json tree in json Payload-> ABC.json

"portedHistory": {
                    "portedDate": "2020-04-12",
                    "numberOfPorts": 3,
                    "portedSinceXDays": 1170,
                    "currentCarrierCircle": "Verizon Verizon Wireless",
                    "originalCarrierCircle": "T-Mobile T-Mobile US",
                    "changeInCarrierRegion": "NOT_SUPPORTED",
                    "portedEvents": [
                        {
                            "carrierCircle": null,
                            "portedDate": "2020-04-12"
                        },
                        {
                            "carrierCircle": null,
                            "portedDate": "2016-05-11"
                        },
                        {
                            "carrierCircle": null,
                            "portedDate": "2016-05-11"
                        }
                    ]
                }

In karate.feature file

Scenario Outline:  ABC_Automation discreption - <Scenario>
    Given url requestUrl
    And def payload = read("<Scenario>.json")
    And headers headers
    And request payload.request
    * set payload.response.portedHistory.portedSinceXDays = "#Ignore" --->not working for number
    * set payload.response.portedHistory.currentCarrierCircle = "#ignore" --> working for string
    When method POST
    * print payload.request
    * print payload.response
    * print karate.pretty(response)
    Then status <statusCode>
    And match $ contains payload.response.portedHistory


    Examples:
      | Scenario  | statusCode |                                                                            
      | ABC.json  | 200        |
     

i want #ignore to be working for dynamic field "portedSinceXDays" which changes daily, So i tried #ignore for ported since. which is not working for number datatype.

few can suggest to validate the response outside with individual key, but as i cant do that because my json response is pretty dynamic and i need to validate for different region data.

Please help me to resolve the issue.

In karate.feature file

Scenario Outline:  ABC_Automation discreption - <Scenario>
    Given url requestUrl
    And def payload = read("<Scenario>.json")
    And headers headers
    And request payload.request
    * set payload.response.portedHistory.portedSinceXDays = "#Ignore" --->not working for number
    * set payload.response.portedHistory.currentCarrierCircle = "#ignore" --> working for string
    When method POST
    * print payload.request
    * print payload.response
    * print karate.pretty(response)
    Then status <statusCode>
    And match $ contains payload.response.portedHistory


    Examples:
      | Scenario  | statusCode |                                                                            
      | ABC.json  | 200        |
     
  • sorry, I'm going to skip this question until you can simplify the payload to be bare-minimum instead of forcing us to read all the json you have. until then I'm pretty sure that you can find the answer you need here: https://stackoverflow.com/a/53120851/143475 - and here's a warning, based on your question, I think you are falling into the trap of overly-clever tests, so please read this also: https://stackoverflow.com/a/54126724/143475 – Peter Thomas Jun 26 '23 at 11:47

0 Answers0