httprunner 3.x學習6 - 生成 html 測試報告


前言

HttpRunner 3.x版可以使用所有的 pytest 插件,包括測試報告插件,像的 pytest-html 和 allure-pytest 。

pytest-html

httprunner 安裝的時候,會自動安裝 pytest 和 pytest-html 插件,對應的版本號是

  • pytest 5.4.3
  • pytest-html 2.1.1
C:\Users\dell>pip show pytest
Name: pytest
Version: 5.4.3

C:\Users\dell>pip show pytest-html
Name: pytest-html
Version: 2.1.1

hrun 生成報告

hrun 命令生成報告的時候,帶上 --html 指定報告路徑

>hrun testcases/login_userinfo_test.py --html=./reports/result.html

--html 參數生成的報告,css文件是單獨分開的,不方便查看,可以加上--self-contained-html參數讓css文件集成到html上

>hrun testcases/login_userinfo_test.py --html=./reports/result.html --self-contained-html

運行結果

查看html報告

pytest 生成報告

用 hrun 運行生成的報告會出現一大堆的報錯: OSError: [WinError 6] 句柄無效。並且無法顯示 request 和 response 內容。
hrun 執行pytest用例還不太完善,盡量用pytest去執行py腳本

>pytest testcases/login_userinfo_test.py --html=./reports/result.html --self-contained-html

執行后查看報告

allure 報告

httprunner3 也可以支持 allure 插件,需 pip 安裝

> pip install allure-pytest

相關教程看這篇https://www.cnblogs.com/yoyoketang/p/12004145.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM