本文介绍了空手道从上一个方案响应中提起的调用失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的代码,我想将场景1响应中的CartItemId用作对场景2的请求,但场景无法获取其值.
Below is my code, i want to use CartItemId from scenario1 response as request for scenario2, but scenario cannot get its value.
Scenario: /api/wishlist/item/add - add to wishlist
Given path '/api/wishlist/item/add'
And headers allHeaders.HeadersToken
And request {"CultureCode":"CHS","IsSpecificSku":0,"MerchantId":"#(data.StyleMerchantId)","SkuId":"#(data.SkuId)","UserKey":"#(data.UserKey)"}
When method POST
Then status 200
* def CartItemId = response.CartItems[0].CartItemId
* print CartItemId
* print response
Scenario: /api/wishlist/item/remove - remove from wishlist
Given path '/api/wishlist/item/remove'
And headers allHeaders.HeadersToken
And request {"CartItemId":"#(CartItemId)","CultureCode":"CHS","UserKey":"#(data.UserKey)"}
When method POST
Then status 200
推荐答案
您要在此处测试流",即先添加,然后删除".请把两个Scenario
合为一个.
You are trying to test a "flow" here which is "first add, then remove". Please combine the two Scenario
s into one.
此处的详细答案: https://stackoverflow.com/a/46080568/143475
这篇关于空手道从上一个方案响应中提起的调用失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!