空手道中的场景大纲,用于多行JSON

时间:2019-05-15 16:56:43

标签: karate

如何使用方案大纲来迭代不仅仅是单个单元格的JSON

https://github.com/intuit/karate#the-cucumber-way

Data.json

[{
    "address": {
        "addressLine1": "ttes",
        "addressLine2": "Test",
        "addressLine3": "Test",
        "addressType": "business",
        "city": "TEST",
        "company": "TEST",
        "country": "TEST",
        "state": "TEST",
        "postalCode": "XXXX"
    },
    "name": {
        "firstName": "TEST",
        "lastName": "TEST",
        "middleInit": "T",
        "title": "Mr."
    },
    "phone": {
        "phoneExtension": "1234",
        "phoneNumber": "999999999",
        "phoneType": "mobile"
    },
    "email": {
        "emailAddress": "TEST@TEST.com"
    }
},
{
    "address": {
        "addressLine1": "ttes1",
        "addressLine2": "Test1",
        "addressLine3": "Test1",
        "addressType": "business",
        "city": "TEST1",
        "company": "TEST1",
        "country": "TEST1",
        "state": "TEST1",
        "postalCode": "XXXX"
    },
    "name": {
        "firstName": "TEST1",
        "lastName": "TEST1",
        "middleInit": "T",
        "title": "Mr."
    },
    "phone": {
        "phoneExtension": "1234",
        "phoneNumber": "999999999",
        "phoneType": "mobile"
    },
    "email": {
        "emailAddress": "TEST@TEST1.com"
    }
}]

====

Feature: Read from File

Background:
* def Testdata = read('Data.json')

Scenario Outline: [1] Test with multiple records on JSON

Given url_stg
And path 'test','test' 
And request Testdata
When method POST  

Examples:
|Testdata   |

1 个答案:

答案 0 :(得分:1)

由于您的情况非常直接,请参阅本文档。

dynamic-scenario-outline

请参阅此答案以了解向Scenario Outline:提供数据的不同方式

https://stackoverflow.com/a/56135752/8615449