文章目錄
- 前言
- 問題一:module 'allure' has no attribute 'severity_level'
- 問題二:ERROR:file or directory not found: ‐vs
- 問題三:生成的 html 報告是空的,明明有測試用例執行完成,但報告沒有顯示數據
前言
pytest+allure+allure-pytest 報告輸出需要安裝以下框架和插件,具體實現可參考:08 接口自動化-用例管理框架pytest之fixtrue,conftest.py,allure報告
框架:
- pytest
- allure
插件:
- pytest-html
- pytest-xdist
- pytest-ordering
- pytest-rerunfailures
- allure-pytest
由于這些框架和插件如果版本不適配,就會導致各種報錯,本人踩過的坑記錄下來,方便自己的同時方便他人,有什么問題,歡迎大家留言評論~
問題一:module ‘allure’ has no attribute ‘severity_level’
原因:pytest-allure-adaptor 兼容 pytest 版本 <5.0;allure-pytest 兼容 pytest 版本>5.0
- 通過
pip show pytest --version
命令查看 pytest 版本,若大于 5.0,則需要執行 pip uninstall pytest-allure-adaptor
pip install allure-pytest
問題二:ERROR:file or directory not found: ‐vs
這是執行pytest -vs
命令報錯,出現這種問題有兩種情況:
- 1、pytest 版本 可能與 python 版本、allure-pytest 版本不適配問題導致的,需要查清楚安裝版本是否彼此相互支持相互適配
- 查看軟件包信息,看支持的情況:
- 查看官方文檔 allure-pytest + pytest
- 網上查詢
- 通過 pip3 安裝,看是否給出版本不適配的警告提示
- 本人環境參考:python 3.10 + allure-pytest 2.14.2 + pytest 7.2.2
- 查看軟件包信息,看支持的情況:
- 2、在 pycharm
終端
執行pytest -vs
命令 和 main 函數執行pytest.main(['-vs'])
沒問題,但在 ini 文件中配置參數執行會報錯
在 終端和main函數執行后,重新在 ini 文件中配置參數執行,又恢復正常。不知道是什么原因導致的,莫名其妙地解決了~
問題三:生成的 html 報告是空的,明明有測試用例執行完成,但報告沒有顯示數據
這是由于 allure 和 allure-pytest 版本不適配導致的
本人環境參考:allure-2.30.0 + allure-pytest-2.14.2