Feature File 1:inputData.feature
@ignore
Feature: Input data table
Scenario: Input table for testing
* table testData
| accountId | accountname | expectedAccount |
| 'ADS5678543' | 'Peter' | 'DFCVSAEFRG' |
| 'ASDCF45678' | 'Caroline' | 'DFCWEAEFRG' |
File 2: payload.json
{
"channelData": {
"data": "CHANNEL_DATA",
"salesChannel": "WEB",
"createdBy": "WEBSITE",
"accountId": "#(accountId)",
"sessionId": "#(accountname)"
}
}
File 3: Request.feature
@ignore
Feature:
Scenario:
# read the payload from json file
* def Request = read('../payload.json')
* def headersData = { "Content-Type" : "application/json"}
Given url BaseUrl + '/account/'+'#(accountId)'
And request Request
And headers headersData
When method post
Then status 200
* print response
* def account = karate.jsonPath(response, "$.account")
* print 'account is '+account
Then match account == '#(expectedAccount)'
File 4: addressinfo.feature
@ignore
Feature:
Scenario:
* def Request = “{
“accountId": "#(resAccount)”
}
”
* def headersData = { "Content-Type" : "application/json"}
Given url BaseUrl +'#(resAccount)’+'/address’
And request Request
And headers headersData
When method post
Then status 200
* print response
File5: Account-token.feature
Feature:
Scenario: identify the reference account
* def initTestData = read('../inputData.feature')
* def reqRes = karate.call('../Request.feature', { initTestData : initTestData })
* def resAccount = $reqRes[*].account // output of this is [“SB987658”,”SB984345”]
* def addressData = read('../addressinfo.feature’,{resAccount: resAccount})
In the above scenario, we have to pass the output of Request.feature as input to addressing.feature. java.net.URISyntaxException: Illegal character in path at index 34: http://10.36.145.196:9983/invoker/[“SB987658”,”SB984345”]/address . Our requirement is it should iterate each value of resAccount and we need to pass the o/p response of addressinfo.feature as I/p to another feature file.