payload.json
{
"channelData": {
"data": "CHANNEL_DATA",
"salesChannel": "WEB",
"createdBy": "WEBSITE",
"accountId": "#(accountId)",
"sessionId": "#(accountname)"
}
}
Request.feature
@ignore
Feature:
Scenario:
* 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
account.feature
@ignore
Feature:
Scenario:
* print temp
* def headersData = { "Content-Type" : "application/json"}
Given url BaseUrl + '/accountdata/'
And request temp
And headers headersData
When method post
Then status 200
帐户令牌功能
Feature:
Scenario: identify the reference account
* def reqRes = karate.call('../Request.feature')
* def temp = karate.pretty(reqRes)
* def account = karate.call('../requests/account.feature',{temp : temp })
我想将Request.feature的响应作为account.feature的请求有效负载传递。当我尝试上述情况时,temp的值将打印在数组中。 [Request.feature的#response]如何解决此问题。
答案 0 :(得分:1)
请仔细研究该示例,它将回答您遇到的所有问题,并且您会发现问题出在哪里:call-feature.feature
例如,要从response
结果中提取call
,您必须对其进行“解压”:
Scenario: create kittens
* def result = call read('create-two-cats.feature')
* def temp = result.response