一、安装allure-pytest模块
二、下载转换工具
这个工具主要用来把测试用例的运行结果转换成html格式
去GitHub上下载:https://github.com/allure-framework/allure2/releases
三、下载完成后解压到本地,并把bin目录添加到环境变量
四、运行
pytest test_allure_demo.py --alluredir ./report
–alluredir参数的作用是指出生成的报告文件夹,这里命名为report
五、查看报告
allure serve report
六、装饰器使用方法
–allure-severities=SEVERITIES_SET
Comma-separated list of severity names. Tests only
with these severities will be run. Possible values
are: blocker, critical, normal, minor, trivial.
–allure-epics=EPICS_SET
Comma-separated list of epic names. Run tests that
have at least one of the specified feature labels.
–allure-features=FEATURES_SET
Comma-separated list of feature names. Run tests that
have at least one of the specified feature labels.
–allure-stories=STORIES_SET
Comma-separated list of story names. Run tests that
have at least one of the specified story labels.
–allure-link-pattern=LINK_TYPE:LINK_PATTERN
Url pattern for link type. Allows short links in test,
like ‘issue-1’. Text will be formatted to full url
with python str.format().
选择运行你要执行epic的用例
pytest --alluredir ./report/allure --allure-epics=epic对大Story的一个描述性标签
选择运行你要执行features的用例
pytest --alluredir ./report/allure --allure-features=模块2
选择运行你要执行features的用例
pytest --alluredir ./report/allure --allure-stories=“用户故事:1”
4.生成html报告
方式一
语法:
allure serve allure报告目录
例如:
allure serve Report
运行命令后,会自动在浏览器中弹出allure访问地址,并显示当前执行结果报告
方式二
(推荐)
语法:allure generate report_path -o out_report --clean
例如:
allure generate Report -o Report/html --clean
运行命令后,会在Report/html目录中生成一个html的报告文件
“–clean”: 清空测试报告目录,再生成新的测试报告,不然测试报告不会刷新
4705cb2b01873896383328de180bf202.png
用浏览器打开 index.html 文件,就可以看到酷炫的html报告了
59a70b149adc4f8081613dcea88f2c34.png
下篇文章将分享 Allure 代码实战
相关资源:allure-2.7.0.zip_allure安装包,allure包下载-互联网文档类资源…
转载:https://blog.csdn.net/weixin_42138788/article/details/118299498