一、安裝
allure-pytest安裝 :
安裝 allure-pytest 第三方庫,命令>> pip install allure-pytest
安裝allure:
allure官網文檔: 官網
下載安裝 github內的allur下載鏈接;
選擇版本,點擊【Download】,下載後得到
allure-commandline-2.13.1 壓縮文件後解壓,將裏面的Allure文件移動至自定義目錄。
配置環境變量
進入Allure的bin目錄,複製路徑,確認即可;
WIN7需要添加;結尾(英文分號)
2. 打開電腦屬性>> 點擊【更改設置】>>【高級】>>【環境變量】>>【系統變量】>>【Path】;
在Path添加Allure的bin目錄路徑,
3、驗證 cmd 輸入 allure --version
import allure
@allure.feature('postman')
@allure.story('postman-api')
@pytest.mark.parametrize('data_dict', test_data)
def test_login(self, data_dict):
logger.info("獲取行數據:%s." % data_dict)
if __name__ == '__main__':
pytest.main(['-s', '-v', 'test_Login2.py', '--html=../report/report.html', '--alluredir','../report/allure-results'])
目錄結構
report
allure-resuilts
cd 到report目錄
allure generate ./allure-results/ -o ./reporthtml/ --clean
打開index.html,在pycharm去打開,直接去路徑打開不OK