版本對應:
python3.4==>allure-pytest2.7.0
python3.6==>allure0pytest2.8.6
環境安裝:
1.先安裝好對應的python,准備好pytest腳本
2.安裝allure-pytest
pip install allure-pytest==version(python適配的版本號)
3.下載allure命令行工具
github地址--可以下載最新版本:
https://github.com/allure-framework/allure2/releases
把解壓后的文件存放到一個目錄下
在path中添加環境變量
在cmd命令窗口中輸入以下命令,出現版本號則可以執行下一步
allure --version
切換到pytest腳本目錄下,
執行存放allure報告的路徑命令:
pytest --alluredir ./report/allure_raw
cmd中運行報告:
allure serve report/allure_raw
========================================================================
要在allure報告上顯示內容的語法:
先在腳本中導入allure
# 在報告上顯示的模塊名 @allure.feature("===login===") class TestLogin(): # 在報告上顯示的用例名 @allure.story("==test_login==")
# 禪道的bug的鏈接地址,在報告上可點擊進行跳轉
@allure.issue("url")
# 禪道的用例鏈接地址,在報告上可點擊進行跳轉
@allure.testcase("url") def test_login(self): chrome_options = webdriver.ChromeOptions()
# 在報告上顯示的步驟名
@allure.step("==test_login==")