如何跑场景用例呢
1.数据关联方法
在上一个接口的数据内定义id,在下一个接口内使用dependent进行关联,举例
# 接口1数据
{
"ins":{
"card_type":"4",
"scan_reference":"test_$2current_subtle_unix_str",
"type":"1"
},
"id": "test_submit_card_type",
"outs":{"id": "0"},
"tags":[
"au"
],
"title":"添加证件类型及scanReference"
}
# 接口2数据
{
"ins":{
},
"dependent": "test_submit_card_type",
"outs":{"id": "0"},
"tags":[
"au"
],
"title":"添加证件类型及scanReference"
}
可以无限循环依赖下去,但是需要记得,当一个接口的数据被多个地方依赖的时候,该接口数据就会被执行多次
2.如何使用上个接口的数据呢
在上一个接口对应的case内使用data_conversion.append_tmp
,如
def test_01(self, data_conversion, data):
ins, outs = data_conversion.get('ins', 'outs')
response = self.send_post_request("submit_card_type", ins)
self.check_response(response, outs)
data_conversion.append_tmp(response)
在下一个接口对应的数据内可使用如下运用
$1JSON[dpTmp] #append_tmp的内容
$1JSON[lastTmp] #上一条用例的数据