Ashwith Rai
Ashwith Rai

Reputation: 35

Scenario Outline in Karate for multi-line JSON

How to use scenario outline to iterate for a JSON which is more than single cell

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": "[email protected]"
    }
},
{
    "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": "[email protected]"
    }
}]

====

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   |

Upvotes: 1

Views: 3401

Answers (1)

Babu Sekaran
Babu Sekaran

Reputation: 4239

Please refer it in this documentation as it very straight forward for your case.

dynamic-scenario-outline

refer to this answer for different ways of providing data to Scenario Outline:

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

Upvotes: 0

Related Questions