首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在空手道框架中,如果满足某个条件,是否可以定义变量?

在空手道框架中,如果满足某个条件,是否可以定义变量?
EN

Stack Overflow用户
提问于 2020-05-20 16:21:54
回答 1查看 134关注 0票数 1

例如:如果保险=真(在JSON响应中),那么定义变量(insurance_img_cancel、insurance_img_refund、insurance_details等)。从接口响应(将在链中的下一个接口中使用),否则抛出消息“保险不可用”。

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-20 18:22:43

这个match还不够吗:

并与response.data.insuranceAvailable == 'true‘匹配

因此,如果它不是真的,它将无法通过测试。这就是你想要的,对吧?

否则请简化问题:https://stackoverflow.com/help/minimal-reproducible-example

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61908363

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档