首先看了卡斯的这篇帖子打造接口测试框架 -- 架构篇,讨论后,研究了下组合测试
本次研究的是 PICT 工具应用到接口测试中生成组合参数
用更少的组合更简洁的用例,让覆盖率不减少,组合测试的分类:
较好的测试组合的原则就是
接口设置参数说明
配置登录接口 txt
user_name:user_name:empty:true:type:bool, user_name:right:1851111111:type:str, user_name:error:18522222222:type:str, user_name:format-error:18522222:type:str
pwd:pwd:empty:true:type:bool, pwd:right:111111:type:str, pwd:error:222222:type:str
code:code:empty:true:type:bool, code:right:1234:type:str, code:error:3333:type:str
生成参数
pict login.txt >login_result.txt
# 生成后txt的接口如下:
user_name pwd code
user_name:format-error:18522222:type:str pwd:empty:true:type:bool code:right:1234:type:str
user_name:right:1851111111:type:str pwd:right:111111:type:str code:right:1234:type:str
user_name:empty:true:type:bool pwd:error:222222:type:str code:empty:true:type:bool
user_name:format-error:18522222:type:str pwd:error:222222:type:str code:error:3333:type:str
user_name:error:18522222222:type:str pwd:empty:true:type:bool code:empty:true:type:bool
user_name:format-error:18522222:type:str pwd:right:111111:type:str code:empty:true:type:bool
user_name:right:1851111111:type:str pwd:empty:true:type:bool code:error:3333:type:str
user_name:empty:true:type:bool pwd:error:222222:type:str code:right:1234:type:str
user_name:empty:true:type:bool pwd:right:111111:type:str code:error:3333:type:str
user_name:right:1851111111:type:str pwd:error:222222:type:str code:empty:true:type:bool
user_name:error:18522222222:type:str pwd:right:111111:type:str code:error:3333:type:str
user_name:error:18522222222:type:str pwd:error:222222:type:str code:right:1234:type:str
user_name:empty:true:type:bool pwd:empty:true:type:bool code:error:3333:type:str
def read_pict_param(pict_params, method):
'''
读取本地生成好了的接口请求参数
:param pict_params: 本地路径
:return: list
'''
result = operateFile.read_txt(pict_params)
l_result = []
if result:
for info in range(len(result)):
if info != 0:
for item in range(len(result[info])):
t_result = result[info][item].split(",")
d_t = {}
for i in t_result:
temp = i.split(":")
t = {}
# print(temp)
t[temp[1]] = temp[2]
t[temp[3]] = temp[4]
d_t[temp[0]] = t
l_result.append(d_t)
return l_result
if __name__ == "__main__":
t = read_pict_param(get_variable.PICT_PARAMS_RESULT, "")
print(t)
后面的接口测试,也会对接进来
@kasi 欢迎一起探讨下