天天看點

Pytest環境搭建二、Allure環境搭建

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

Pytest環境搭建二、Allure環境搭建

二、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

Pytest環境搭建二、Allure環境搭建

3. 配置allure環境變量到path路徑。

我的電腦-右擊屬性-進階系統設定-環境變量-編輯系統環境變量path路徑追加allure路徑-點選确定。

Pytest環境搭建二、Allure環境搭建
Pytest環境搭建二、Allure環境搭建
Pytest環境搭建二、Allure環境搭建
Pytest環境搭建二、Allure環境搭建

4.  驗證配置成功

打開cmd,輸入allure,出現下面圖,說明配置成功

Pytest環境搭建二、Allure環境搭建