pytest-Allure報(bào)告
參考:http://www.rzrgm.cn/yoyoketang/p/12004145.html
安裝
- pip install pytest
- pip install allure-pytest
- 安裝allure
github下載https://github.com/allure-framework/allure2/releases
下載后解壓到本地\Python\Python38\Lib\site-packages
配置環(huán)境變量,添加指向到bin的文件。 Python\Python38\Lib\site-packages\allure-2.13.5\bin - 驗(yàn)證
安裝后,cmd輸入allure,如果出現(xiàn)報(bào)錯(cuò)module 'allure' has no attribute 'severity_level',
說明allure-pytest與 pytest-allure-adaptor不能共存,寫在 pytest-allure-adaptor即可,卸載pip uninstall pytest-allure-adaptor
使用
- 執(zhí)行
在可以運(yùn)行pytest的路徑下
cmd:pytest --alluredir ./report
pycharm:
args = ['-m', 'loginTest', '--alluredir', "./allureReport"] # 生成allure報(bào)告
pytest.main(args) - 整理
cmd:allure generate report/ -o report/html --clean report
pycharm:切換到terinal下,輸入allure generate report/ -o report/html --clean report - 查看
會(huì)在report下生成一個(gè)html文件夾,打開其中的index.html
![]()
![]()
配置
可以有很多高級(jí)的使用,比如與Jenkins連用。



浙公網(wǎng)安備 33010602011771號(hào)