一、Pytest環境搭建
Pytest 是 python 的第三方單元測試框架,比自帶 unittest 更簡潔和高效,
支持315種以上的插件,同時兼容 unittest 框架,
在 unittest 框架遷移到 pytest 框架的時候不需要重寫代碼
環境搭建:
首先安裝pytest庫:
pip install pytest
pip install pytest-html#原生態報告
若下載失敗可以使用豆瓣源下載:
pip install pytest -i http://pypi.douban.com/simple/
pip install pytest-html -i http://pypi.douban.com/simple/
查看安裝是否成功:
pip show pytest
二、Allure環境搭建
Allure 是一款輕量級的開源自動化測試報告生成框架。它支持絕大部分測試框架,比如 TestNG、 Junit 、pytest、unittest 等。本文主要介紹 pytest 框架結合 Allure 生成 格式統一、美觀的 測試報告。
1. 安裝pytest-allure庫:
pip install allure-pytest
報錯可以使用豆瓣源:
pip install allure-pytest -i http://pypi.douban.com/simple/
2. 接口課前准備里網盤鏈接,下載allure到任意目錄並解壓。
鏈接:https://pan.baidu.com/s/1Jd98aXePkyyMbBytx-2IZA
提取碼:2mxs
3. 配置allure環境變量到path路徑。
我的電腦-右擊屬性-高級系統設置-環境變量-編輯系統環境變量path路徑追加allure路徑-點擊確定。
4. 驗證配置成功
打開cmd,輸入allure,出現下面圖,說明配置成功