allure-pytest生成測試報告,經過實踐得出如下經驗,參考了很多大神的博客一並附上
1、安裝allure-pytest
pip install allure-pytest
2、執行命令生成json和txt文件:
pytest tests --alluredir report/allure_raw
pytest test_setupAndteardown --alluredir report/allure_raw
如果過程中報錯AttributeError: module 'allure' has no attribute 'severity_level'則執行:
pip uninstall pytest-allure-adaptor
pip install allure-pytest
3、我們執行命令后拿到的是json和txt格式文件不是我們期望的可打開html圖形界面
我們需要從官網下載最新allure 的zip文件,解壓放置項目lib文件夾下
4、執行命令
allure generate <allure測試結果目錄> -o <存放報告的目錄> --clean
allure測試結果目錄,是上面運行 pytest 命令后存放結果的地方,我們這里的目錄是 report 下的 allure_raw 文件夾;
存放報告的目錄,是最終生成的測試報告存放的目錄,我打算把生成出的報告放在 report 下的 allure_report文件夾中;
--clean參數用來清空已有的報告,避免覆蓋時出錯。
python參考文檔:
https://www.jianshu.com/p/54a88c8a8bc8?utm_campaign=hugo&utm_medium=reader_share&utm_content=note&utm_source=qq
--java參考地址:
https://blog.csdn.net/qq_39421886/article/details/99562698