四、pytest结合allure-pytest插件生成allure测试报告

一、下载,解压,配置path路径

1.1 下载并解压

https://github.com/allure-framework/allure2/releases

1.2 配置环境变量

将 bin 目录加载到环境变量中

1.3 验证

allure --version

 如果 pycharm验证失败,那么重启 pycharm就可以了

二、生成 json 格式的临时报告

[pytest]

addopts = -vs --alluredir ./temp
testpaths = ./
python_files = test*.py
python_classes = Test*
python_functions = test
markers =
    smoke:冒烟模块
    usermanage:用户管理模块
    productmanage:商品管理模块

三、将 json 格式的临时文件生成 allure 报告

os.system('allure generate ./temp -o ./report --clean')
"""
allure generate 命令,固定的
./temp 临时的json格式报告的路径
-o 输出output
./report 生成的allure报告的路径
--clean 清空./report 路径原来的报告
"""

 打开 index.html 就可以生成美观的报告

 

posted on 2024-07-27 20:21  软饭攻城狮  阅读(2)  评论(0编辑  收藏  举报

导航