来自最后一个场景响应的调用失败,空手道失败

时间:2018-01-19 08:09:13

标签: karate

下面是我的代码,我想使用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

1 个答案:

答案 0 :(得分:0)

您正在尝试测试"流程"这是"首先添加,然后删除"。请将两个Scenario合并为一个。

详细答案:https://stackoverflow.com/a/46080568/143475