pytest 框架之pytest html報告生成

2022-06-09 10:03:11 字數 731 閱讀 2835

一、關於安裝

pytest-html屬於pytest的乙個外掛程式,使用它需要先安裝

pip install pytest-html
pytest可以生成多種樣式的結果:

生成 junitxml 格式的測試報告,命令 : --junitxml= path

生成 resultlog 格式的測試報告,命令: --resultlog=report/log.txt

生成 html 格式的測試報告,命令: --html=outputs/reports/report.html (相對路徑)

二、生成html報告

import

pytest

if__name__ == '

__main__':

# 生成pytest-html報告

pytest.main(['-s

', '

-v', '

--html=outputs/reports/report.html

'])

生成的測試報告位置:

開啟測試報告:

*******尊重作者,本文是本人**自:

******* 

pytest框架介紹

一 pytest介紹 pytest是python的一種單元測試框架,與python自帶的unittest測試框架類似,但是比unittest框架使用起來更簡潔,效率更高。它具有如下特點 1.非常容易上手,入門簡單,文件豐富,文件中有很多例項可以參考 2.能夠支援簡單的單元測試和複雜的功能測試 3.支...

pytest框架之pytest html報告生成

pytest html屬於pytest的乙個外掛程式,使用它需要先安裝 pip install pytest htmlpytest可以生成多種樣式的結果 生成junitxml格式的測試報告,命令 junitxml path 生成resultlog格式的測試報告,命令 resultlog report...

測試框架 Pytest框架(一)

目錄 pytest的安裝與執行 安裝 執行執行方式及命令 ide中執行 命令列終端執行 生成報告 報告中的亂碼處理 檢查點 斷言 基於python語言的自動化常用的框架有三種,unittest pytest rf。前兩款更多的用於白盒單元測試,rf可以很好的做系統測試使用。安裝pytest pip ...