1、读取csv 数据进行类型转换
一般参数数据放csv文件,csv 文件默认都是字符串类型,有些接口需传 int 类型的数字,比如断言返回值状态码的值断言。读取csv文件的数据后,可进行一下数据转换,可在debugtalk.py 写个辅助函数解决。
def int_to_str(arg):
return str(arg)
def str_to_int(arg):
return int(arg)
.validate()
.assert_equal("status_code", "${str_to_int($statusCode)}") #csv默认是字符串类型,需转换为int
原文链接:https://cloud.tencent.com/developer/article/1706199
2、 测试用例引用前面一个用例(call)
比如查询个人信息接口依赖于先登录(获取token),像这种业务上操作有先后关系的情况,可以把登录当一个step来引用
teststeps = [
Step(RunTestCase("step1 login")
.call(TestLogin)
.export(*["token"])),
Step(
RunRequest("step2 get user info")
.get("/api/v1/userinfo/")
.with_headers(
原文链接:https://blog.csdn.net/qq_27371025/article/details/118079233