https://blog.csdn.net/wust_lh/article/details/86685912
https://www.jianshu.com/p/9673b2aeb0d3
定制化展示數據
https://blog.csdn.net/qw943571775/article/details/99634577
?
環境說明:
jdk = 1.8
python = 3.5.3
allure-commandline = 2.13.0?
文檔及下載地址:https://docs.qameta.io/allure/#_commandline
GitHub:https://github.com/allure-framework/allure2/releases
?
一、下載安裝allure-commandline,配置環境變量
?
1.1 下載合適版本?https://github.com/allure-framework/allure2/releases
?
?
?
1.2 解壓文件并將 bin目錄添加到Path環境變量中
?
?
?
1.3 驗證allure
輸入allure --version,返回版本信息則安裝成功
?
?
?
?二、安裝pytest和pytest-allure
pip install pytest
pip install allure-pytest
注意:網上大多數是安裝pytest-allure-adaptor,這是allure1,現在是allure2了,官方已經不維護1了。
pypi中具體用法已經說得很清楚了https://pypi.org/project/allure-pytest/
?
?三、編寫用例
Test.py
import allure import pytest@allure.feature("Test") class Test:@allure.story("比較數值")def test_01(self):"""這是1號用例:return:"""assert 0 == 0@allure.story("比體積")def test_02(self):"""這是2號用例:return:"""assert 0 == 1
?
四、執行用例
在項目根目錄下執行如下命令,就會執行Test.py模塊中的用例,生成report文件里面存放的是后面報告需要解析的json文件,包含了用例的所有信息。
執行這個Test.py模塊下的用例,--alluredir=report?生成report目錄存放數據,--clean-alluredir 清除原有的存放數據路徑
pytest .\Test.py --alluredir=report --clean-alluredir
?
?
?
?
?五、生成報告
執行命令解析json文件并生成html報告,并啟動服務
allure serve report
?
?
?六、查看報告
?