空手道:从json文件中读取查询参数,并与预期结果进行比较

时间:2019-11-13 01:30:33

标签: karate

Feature: Regression
Background:
        * url BaseUrl
        * def secretKey = uatApiKey
        * configure ssl = true  
        * def endpoint = '/member/detail'
        * def json1 = read('input/memberdetails.json')

Scenario Outline: Regression Scenarios id:  
    * configure headers = { apikey: '#(secretKey)', Accept: 'application/json' }
    Given path endpoint  
    And param id = __row.id
    When method get
    #* def id = <id>
    Then status 200
    And match   response == __row.expected
Examples:
|json1|

仅当memberdetails.json为以下格式时,此方法才有效:

[{“ id”:“ 12345”,“ expected”:{“ member”:{“ Uid”:“ 12345”,“ firstNm”:“ XYZ”,“ lastNm”:“ Y”,“ dob” :“ 1900-01-00”,“性别”:{“代码”:“ M”,},“失败”:[{“ UUid”:“ 12345”,“ ads”:“ 2211”,“ ABCcode”: {“ code”:“ 11”,}}]}}},

{“ id”:“ 345”,“ expected”:{“ member”:{“ Uid”:“ 345”,“ firstNm”:“ abc”,“ lastNm”:“ Y”,“ dob”: “ 1900-01-00”,“性别”:{“代码”:“ F”,},“失败”:[{“ UUid”:“ 12345”,“ ads”:“ 2211”,“ ABCcode”:{ “ code”:“ 12”,}}]}}}}]

如果memberdetails.json文件的格式如下      java.lang.NullPointerException

    [  {
          "id": "12345",
          "expected": {
            "member": {
              "Uid": "12345",
              "firstNm": "XYZ",
              "lastNm": "Y",
              "dob": "1900-01-00",
              "gender": {
                "code": "M",
                 },
              "deail": [
                {
                  "UUid": "12345",
                  "ads": "2211",
                  "ABCcode": {
                    "code": "11",

                  }
                }
              ]
            }
          }
        },{
          "id": "345",
          "expected": {
            "member": {
              "Uid": "345",
              "firstNm": "abc",
              "lastNm": "Y",
              "dob": "1900-01-00",
              "gender": {
                "code": "F",
                 },
              "deail": [
                {
                  "UUid": "12345",
                  "ads": "2211",
                  "ABCcode": {
                    "code": "12",

                  }
                }
              ]
            }
          }
        }

]

0 个答案:

没有答案