Allure的簡單使用
1.Allure簡介
簡單的理解下,可以把Allure當成一個用于生成美觀測驗報告的開源工具,配合Pytest測驗框架使用更佳,
也就是說,Allure是在Pytest執行測驗用例結束后生成的測驗資料的基礎上,對測驗資料進行進一步處理、統計,生成格式統一、美觀的測驗報告,并通過HTML展示,
2.用例描述
| 使用方法 | 引數值 | 引數說明 |
|---|---|---|
| @allure.epic() | epic描述 | 定義專案、當有多個專案時使用, |
| @allure.feature() | 模塊名稱 | 用例按照模塊區分,有多個模塊時給每個模塊起個名字 |
| @allure.story() | 用例名稱 | 對于一個用例的描述 |
| @allure.title() | 用例標題 | 一個用例的標題 |
| @allure.testcase() | 測驗用例的連接地址 | 自動化用例對應的功能用例存放系統的路徑 |
| @allure.issue() | 缺陷地址 | 對應缺陷管理系統里面的缺陷地址 |
| @allure.description() | 用例描述 | 對測驗用例ide詳細描述 |
| @allure.step() | 操作步驟 | 測驗用例的操作步驟 |
| @allure.severity() | 用例等級 | blocker\critical\normal\minor\trivial |
| @allure.link() | 定義連接 | 用于定義一個需要在測驗報告中展示的鏈接 |
| @allure.attachment | 附件 | 添加測驗報告附件 |
3.Pytest集成Allure
Allure要生效需要在測驗檔案和測驗通配檔案(conftest.py)中配置Allure,具體見示例專案地址根目錄下conftest.py檔案
├─api_src 介面與介面串聯
│ ├─apis 介面
│ │ └─question 一個功能模塊
│ └─process 處理程序
│ └─question
├─data_io
| ├─allure
| ├─report 測驗報告
│ └─result 結果資料
├─page 頁面測驗
├─test_case 測驗用例
│ └─modules 多模塊
│ ├─question
│ ├─question_batch
│ └─report
├─test_data 測驗資料
│ ├─original 原始.har資料
│ └─question yml資料
└─utils 封裝的工具類
class TestQuestion(BasicCase):
@allure.feature("題庫管理")
@allure.story("題目-增查刪改")
@pytest.mark.all
@pytest.mark.question
def test_question_add_search_update_delete(self):
logger.info("==============Case:[題目-增查刪改]開始執行==============")
question_process.question_add_search_update_delete()
logger.info("==============Case:[題目-增查刪改]結束執行==============")
4.生成測驗報告
if __name__ == '__main__':
result_path, report_path = config.allure_report_path()
test_case = config.get_test_case_path()
# pytest生成測驗報告
pytest.main(["-vs", test_case, "-m question_batch", "--env=admin", "--isc=False", "--is_vc=True",
"--email=False",
"-sq", "--alluredir", result_path])
# allure生成測驗報告
os.system("allure generate {} -o {} --clean ".format(result_path, report_path))
# 打開測驗報告
os.system("allure open {}".format(config.report_path()))
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/499834.html
標籤:Python
上一篇:Python生成字母對后寫入檔案
