HttpRunner3.X学习笔记(7)- 测试报告

2020-09-22  本文已影响0人  是立品啊

HTTPrunner 集成了 pytest,所以 HTTPrunner v3.x可以使用pytest 的所有插件,包括测试报告插件,例如pytest-htmlalluer-pytest

HTML 测试报告

HTTPrunner 安装之后自带 pytest-html插件,当你想生成 HTML测试报告时,可以添加命令参数--html

 hrun testcases/dlvopenapi/dlvopenapi_success_test.py --html=test.html

-·-html=test.html`中的test.html是测试报告的存放路径,没有带文件夹的时候会存放在命令运行的当前文件夹,此处是项目根目录

image.png

生成的报告如下

image.png

allure report

pytest 支持大名鼎鼎的 allure 测试报告,HTTPrunner 集成了pytest,也天然支持allure

不过 HTTPrunner 默认并未安装 allure,你需要另外安装。

安装有两种方式:

安装 allure-pytest:

pip3 install allure-pytest

安装 httprunner[allure](推荐)

pip3 install "httprunner[allure]"

一旦allure-pytest 准备好,以下参数就可以与 hrun/pytest命令一起使用:

要使 Allure 侦听器能够在测试执行期间收集结果,只需添加--alluredir选项,并提供指向存储结果的文件夹路径。如:

hrun testcases/dlvopenapi/dlvopenapi_success_test.py --alluredir=/tmp/my_allure_results
image.png

/tmp/my_allure_results 只会存储收集的测试结果并非完成的报告,还需要通过命令生成。

要在测试完成后查看实际报告,您需要使用Allure命令行实用程序从结果中生成报告。

allure serve /tmp/my_allure_results
image.png

此命令将在默认浏览器中显示你生成的报告。


image.png

同时你也可以在 Jenkins 中安装 allure 报告插件,将结果与Jenkins 集成。

上一篇 下一篇

猜你喜欢

热点阅读