1.用例环境

This commit is contained in:
mojin 2023-02-02 12:24:57 +08:00
parent 7afb4b5993
commit 7762d05e57
22 changed files with 211 additions and 15 deletions

View File

@ -22,6 +22,9 @@ class Api_Request():
@classmethod
def api_data(cls,cases,env_url):
url,env=env_url #环境url
allure.dynamic.story(cases[0])
del cases[0]
@ -86,13 +89,13 @@ class Api_Request():
Logger.info(case_title)
allure.dynamic.title(case_title)
allure.dynamic.description("【用例名称】:%s\n\n【请求地址】:%s%s\n\n【请求参数】:%s"%(case_title,env_url,path,data))
#allure.dynamic.link('%s%s'%(env_url,path), name='%s%s'%(env_url,path)) # 关联的连接
allure.dynamic.description("【用例名称】:%s\n\n【请求地址】:%s%s\n\n【请求参数】:%s"%(case_title,url,path,data))
#allure.dynamic.link('%s%s'%(url,path), name='%s%s'%(url,path)) # 关联的连接
pattern = re.compile(r'^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+')
if (pattern.search(path)) == None: # 判断读取的地址是否有前缀地址http://192.168.1.153:8562
urls ="%s/%s"%(env_url,path) # 无前缀读取配置文件添加前缀
urls ="%s/%s"%(url,path) # 无前缀读取配置文件添加前缀
else:
urls = path # 有前缀使用读取的完整地址

View File

@ -10,9 +10,9 @@ server:
Operations_db: # 操作数据库
assert_db: True # True 启用数据库查询断言 False 不启用
backup: True #启动测试前启动备份数据库 数据库服务器 linux适用windows不适用
recovery: True #测试完成后恢复备份数据库 数据库服务器 linux适用windows不适用
assert_db: False # True 启用数据库查询断言 False 不启用
backup: False #启动测试前启动备份数据库 数据库服务器 linuxwindows都适用
recovery: False #测试完成后恢复备份数据库 数据库服务器 linuxwindows都适用
severity:
@ -31,17 +31,17 @@ request_headers: {"peachauthversioncode": "${versioncode}","appversioncode": "${
extra_pool: {"userAccount": "ceshi6","password": "Hj123456","org_id": 176,"tenant_id": 1,"token":'',"versioncode": "9","singleBatch": False}
# 基准的请求参数
request_parameters: {"Au": "Au"}
request_parameters: {}
test_case_type: # 用例读取的来源 为True读取文件类型为False不读取,如excel 和yaml都为True时 读取累加
dev:
- read: True # True 读取excle文件中的用例 False 不读取
test_case: ./data/case_excle/
test_case: ./data/env_dev/case_excle/
file: xlsx
order: 1 #顺序
- read: True # True False 读取yaml文件中的用例
test_case: ./data/case_yaml/
test_case: ./data/env_dev/case_yaml/
file: yaml
order: 0 #顺序
@ -49,23 +49,23 @@ test_case_type: # 用例读取的来源 为True读取文件类型为False
test:
- read: True # True 读取excle文件中的用例 False 不读取
test_case: ./data/case_excle/
test_case: ./data/env_test/case_excle/
file: xlsx
order: 1 #数字排序顺序
- read: True # True False 读取yaml文件中的用例
test_case: ./data/case_yaml/
test_case: ./data/env_test/case_yaml/
file: yaml
order: 0 #数字排序顺序
prod:
- read: False # True 读取excle文件中的用例 False 不读取
test_case: ./data/case_excle/
test_case: ./data/env_prod/case_excle/
file: xlsx
order: 1 #顺序
- read: True # True False 读取yaml文件中的用例
test_case: ./data/case_yaml/
test_case: ./data/env_prod/case_yaml/
file: yaml
order: 0 #顺序

View File

@ -42,7 +42,7 @@ def env_url(Acmdopt):#读取数据源文件
url = ReadFile.read_config('$.server.%s'%Acmdopt)# $..test
Logger.warning('执行环境为:【%s%s' %(Acmdopt_env,url))
return url
return [url,Acmdopt]

View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# @Project : pytest_allure_request_20220811
# @Time : 2023/2/2 11:40
# @Author : mojin
# @Email : 397135766@qq.com
# @File : __init__.py.py
# @Software: PyCharm
# -------------------------------------------------------------------------------

View File

@ -1,7 +1,7 @@
#!/usr/bin/python3.7
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# @Time : 2022/8/11 20:25
# @Time : 2022/8/18 20:38
# @Author : mojin
# @Email : 397135766@qq.com
# @File : __init__.py.py

View File

@ -0,0 +1,15 @@
- - "c1" #序列
- "post请求实现登录" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "login" #请求地址
- "P1" #用例等级
- '${token}!=None' #跳过条件
- "post" #请求方法
- "json" #参数类型
- '' #上传文件
- '{"username":"admin","password":"123456"}' #请求参数
- '{"token": "$...token","userId": "$...id"}' #后置提交参数
- "select * from sp_manager where mg_id=${userId}" #后置执行slq语句
#- '{"$..msg":"登录成功", "$..status":200}' #期望结果 #,"$...username":"$..sql_0_data.mg_name",
- '[["登录成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]

View File

@ -0,0 +1,28 @@
- - "c1" #序列
- "商品列表数据" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "goods" #请求地址
- "P4" #用例等级
- '${token}!=None' #跳过条件
- "get" #请求方法
- "params" #参数类型
- '' #上传文件
- '{"pagenum":"1","pagesize":"10"}' #请求参数
- '{"goods_id": "$...goods.[2].goods_id"}' #后置提交参数
- "" #后置执行slq语句
- '[["获取成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]
- - "c1" #序列
- "商品列表数据" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "goods" #请求地址
- "P4" #用例等级
- '${token}!=None' #跳过条件
- "get" #请求方法
- "params" #参数类型
- '' #上传文件
- '{"pagenum":"1","pagesize":"10"}' #请求参数
- '{"goods_id": "$...goods.[2].goods_id"}' #后置提交参数
- "" #后置执行slq语句
- '[["获取成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]

View File

@ -0,0 +1,29 @@
- - "c1" #序列
- "根据 ID 查询商品" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "goods/${goods_id}" #请求地址
- "P1" #用例等级
- '${token}!=None' #跳过条件
- "get" #请求方法
- "params" #参数类型
- '' #上传文件
- '{}' #请求参数
- '{}' #后置提交参数
- "" #后置执行slq语句
- '[["获取成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]
- - "c1" #序列
- "根据 ID 查询商品" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "goods/${goods_id}" #请求地址
- "P1" #用例等级
- '${token}!=None' #跳过条件
- "get" #请求方法
- "params" #参数类型
- '' #上传文件
- '{}' #请求参数
- '{}' #后置提交参数
- "" #后置执行slq语句
- '[["获取成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]

View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# @Project : pytest_allure_request_20220811
# @Time : 2023/2/2 11:40
# @Author : mojin
# @Email : 397135766@qq.com
# @File : __init__.py.py
# @Software: PyCharm
# -------------------------------------------------------------------------------

10
data/env_test/__init__.py Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# @Project : pytest_allure_request_20220811
# @Time : 2023/2/2 11:40
# @Author : mojin
# @Email : 397135766@qq.com
# @File : __init__.py.py
# @Software: PyCharm
# -------------------------------------------------------------------------------

View File

@ -0,0 +1,9 @@
#!/usr/bin/python3.7
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# @Time : 2022/8/18 20:38
# @Author : mojin
# @Email : 397135766@qq.com
# @File : __init__.py.py
# @Software: PyCharm
#-------------------------------------------------------------------------------

Binary file not shown.

View File

@ -0,0 +1,15 @@
- - "c1" #序列
- "post请求实现登录" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "login" #请求地址
- "P1" #用例等级
- '${token}!=None' #跳过条件
- "post" #请求方法
- "json" #参数类型
- '' #上传文件
- '{"username":"admin","password":"123456"}' #请求参数
- '{"token": "$...token","userId": "$...id"}' #后置提交参数
- "select * from sp_manager where mg_id=${userId}" #后置执行slq语句
#- '{"$..msg":"登录成功", "$..status":200}' #期望结果 #,"$...username":"$..sql_0_data.mg_name",
- '[["登录成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]

View File

@ -0,0 +1,28 @@
- - "c1" #序列
- "商品列表数据" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "goods" #请求地址
- "P4" #用例等级
- '${token}!=None' #跳过条件
- "get" #请求方法
- "params" #参数类型
- '' #上传文件
- '{"pagenum":"1","pagesize":"10"}' #请求参数
- '{"goods_id": "$...goods.[2].goods_id"}' #后置提交参数
- "" #后置执行slq语句
- '[["获取成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]
- - "c1" #序列
- "商品列表数据" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "goods" #请求地址
- "P4" #用例等级
- '${token}!=None' #跳过条件
- "get" #请求方法
- "params" #参数类型
- '' #上传文件
- '{"pagenum":"1","pagesize":"10"}' #请求参数
- '{"goods_id": "$...goods.[2].goods_id"}' #后置提交参数
- "" #后置执行slq语句
- '[["获取成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]

View File

@ -0,0 +1,29 @@
- - "c1" #序列
- "根据 ID 查询商品" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "goods/${goods_id}" #请求地址
- "P1" #用例等级
- '${token}!=None' #跳过条件
- "get" #请求方法
- "params" #参数类型
- '' #上传文件
- '{}' #请求参数
- '{}' #后置提交参数
- "" #后置执行slq语句
- '[["获取成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]
- - "c1" #序列
- "根据 ID 查询商品" #用例名称
- '{"Authorization": "${token}"}' #请求头
- "goods/${goods_id}" #请求地址
- "P1" #用例等级
- '${token}!=None' #跳过条件
- "get" #请求方法
- "params" #参数类型
- '' #上传文件
- '{}' #请求参数
- '{}' #后置提交参数
- "" #后置执行slq语句
- '[["获取成功","==","$..msg","str"],[200,"==","$..status","int"]]' #断言 [期望,断言类型,实际,数据类型 str,int]

View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# @Project : pytest_allure_request_20220811
# @Time : 2023/2/2 11:40
# @Author : mojin
# @Email : 397135766@qq.com
# @File : __init__.py.py
# @Software: PyCharm
# -------------------------------------------------------------------------------