bin config lib plugins
logo定制
allure.yaml增加插件
plugins:
...
-custom-logo-plugin
plugins/custom-logo-plugin/staic/custom-logo.svg
修改样式:plugins/custom-logo-plugin/staic/style.css:
修改样式,图片
2.功能定制
左边:
@allure.epic("自动测试项目") --项目定制
@allure.feature("用户管理模块")--模块定制
class Test:
pass
@allure.story("获取鉴权码接口") --接口名称定制
@allure.title("获取成功") --所有的接口用例只有一个标题
@allure.severity(allure.severity.level.BLOCK)
@allure.link("接口访问地址")
@allure.issue("bug链接")
@allure.testcase("测试用例链接")
def test_01_mashang(self,product):
allure.dynamic.description("描述")
pass
allure.dybamic.title(product+"获取成功") --用例标题取决于数据驱动
for a in range(1,6):
with allure.step("执行第"+str(a)+"个步骤"):
pass
#附件
with open(r"E:\\shu.png",mode="rb") as f:
content=f.read()
#图片
allure.attach(body=content,name="错错误截图", attachment_type=allure.attachment_type.PNG)
#文本
allure.attach(body="接口地址:XX",name="接口地址",attachment_type=allure.attachment_type.TEXT)
右边:
@allure.severity(allure.severity.level.BLOCK)
BLOCK:致命
CRITICL:严重
NORMAL:一般
MINOR:提示
TRIVIAL:轻微
#链接
接口访问地址:
bug链接
测试地址链接:
@allure.link("接口访问地址")
@allure.issue("bug链接")
@allure.testcase("测试用例链接")
步骤:
for a in range(1,6):
with allure.step("执行第"+str(a)+"个步骤"):
pass
附件(web自动胡错误截图,接口自动化文本信息)
with open(r"E:\\shu.png",mode="rb") as f:
content=f.read()
#图片
allure.attach(body=content,name="错错误截图", attachment_type=allure.attachment_type.PNG)
#文本
allure.attach(body="接口地址:XX",name="接口地址",attachment_type=allure.attachment_type.TEXT)
企业中实际的自动化测需要定制:
1.logo定制
2.功能定制
@allure.epic("自动测试项目") --项目定制
@allure.feature("用户管理模块")--模块定制
class Test:
pass
@allure.story("获取鉴权码接口") --接口名称定制
@allure.title("获取成功") --所有的接口用例只有一个
@allure.severity(allure.severity.level.BLOCK)
allure.dynamic.description("描述")
附件(web自动胡错误截图,接口自动化文本信息)
with open(r"E:\\shu.png",mode="rb") as f:
content=f.read()
allure.attach(body=content,name="错错误截图", attachment_type=allure.attachment_type.PNG)
二,Allure报告访问
allure open ./reports
三,pytest之parametrize数据驱动
@pytest.mark.parametrize(args_name,args_value)
args_name:参数名称
args_value:参数值
class TestMS:
@pytest.mark.parametrize("args_name",["a","b","c"])
def test_01_aa(self,args_name):
print(args_name)
pass
@pytest.mark.parametrize("name,age",[["a":'1'],["b":'2'],["c":'3']])
def test_01_aa(self,name,age):
print(name,age)
pass
2,yaml文件
一种数据格式,一般用于配置文件以及接口自动化的用例
由两种数据格式组成:
1.map对象:键:(空格)值
name:baili
get_token.yaml:
-
name:aa
request:
method: get
url: https://api.weixin.qq.com
data:
grant_type:
appid:
secret:
headets: None
validate: None
list列表,用一组-开头。同一个级别一个列表
- name1:baili
-name2:xingyao
pip install pyyaml
yaml_util.py:
def read_yaml(yaml_path):
with open(yaml_path,encoding='utf-8') as f:
value=yaml.load(f,Loader=yaml.FullLoader)
returm value
----
@pytest.mark.parametrize("args_name",read_yaml("./testcases/usermanage/get_token.yaml"))
def test_get_token(self,args_name)
name = args_name['name']
method = args_name['request']['method']
url = args_name["request"]["url"]
data= args_nam["request]["data"]
res = request.get(url=url,data=data)
print(res.json)