pytest allure 生成html测试报告
前提:需要 java 1.8 以上、python3环境
一、下载pytest
pip install pytest
二、下载Allure Pytest Adaptor插件
pip install pytest-allure-adaptor
三、下载allure压缩包
地址:https://github.com/allure-framework/allure2/releases,配置环境变量:path 里添加 安装目录/allure-commandline-2.12.1/bin
四、报错解决
错误:module ‘allure’ has no attribute ‘severity_level’
删除后重新安装,执行以下命令:
pip uninstall pytest-allure-adaptor
pip install allure-pytest
五、运行
测试文件目录下执行 pytest,测试文件必须以 test 开头,支持全部测试用例运行,也可以指定测试用例运行,进入文件测试用例目录下执行
1、指定运行:pytest 测试文件 --alluredir report
pytest test_demo01.py --alluredir report
会在当前文件夹生成 allure-report 文件夹,包含HTML测试报告 index.html
2、全部运行:pytest --alluredir report
pytest --alluredir report
会在当前文件夹生成 allure-report 文件夹,包含HTML测试报告 index.html,含所有测试用例结果数据

浙公网安备 33010602011771号