下面是我的代码,我想使用scenario1响应中的CartItemId作为scenario2的请求,但是方案无法获得其值。
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
答案 0 :(得分:0)
您正在尝试测试"流程"这是"首先添加,然后删除"。请将两个Scenario
合并为一个。