例如:如果保险=真(在JSON响应中),那么定义变量(insurance_img_cancel、insurance_img_refund、insurance_details等)。从接口响应(将在链中的下一个接口中使用),否则抛出消息“保险不可用”。
Given url postEligibility
And def eligibilityRequestBody = read('eligibilityCPReq.json')
And request eligibilityRequestBody
And print eligibilityRequestBody
And def cookie = read('cookie.txt')
And header cookie = cookie
When method Post
Then status 200
And print response
And match **response.data.insuranceAvailable == 'true'**
And def insurance_img_cancel = response.data.img_cancel
And def insurance_img_refund = response.data.img_refund
And def insurance_details = response.data.insurance_details
And def insurance_end_date = response.data.insurance_end_date
And def insurance_id = response.data.insurance_details[0].insurance_id
And def insurance_premium = response.data.insurance_details[0].premium
And def insurance_type = response.data.insurance_type
And def insuranceAvailable = response.data.insuranceAvailable发布于 2020-05-20 18:22:43
这个match还不够吗:
并与response.data.insuranceAvailable == 'true‘匹配
因此,如果它不是真的,它将无法通过测试。这就是你想要的,对吧?
否则请简化问题:https://stackoverflow.com/help/minimal-reproducible-example
https://stackoverflow.com/questions/61908363
复制相似问题