打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
pytest文档13-allure2生成html报告(史上最详细)

前言

allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面。

环境准备

  • 1.python3.6

  • 2.windows环境

  • 3.pycharm

  • 4.pytest-allure-adaptor

  • 5.allure2.7.0

  • 6.java1.8

pytest-allure-adaptor下载

pip安装pytest-allure-adaptor,github地址https://github.com/allure-framework/allure-pytest

pip3 install pytest-allure-adaptor

生成xml报告

pytest -s -q —alluredir report

如果不指定路径,默认在当前目录下新建一个report目录,当然也可以指定路径

pytest -s -q —alluredir 指定report路径

执行完之后打开report文件夹,会自动生成xml格式的报告

安装 Command Tool

allure的版本目前有2个,从github上看,allure1不再被支持,请考虑使用allure2  https://github.com/allure-framework/allure2替代

allure-commandline releases版本https://github.com/allure-framework/allure2/releases

下载最新的Download allure2.7.0版本

[下载Download allure2.7.0 地址:https://dl.bintray.com/qameta/generic/io/qameta/allure/allure/2.7.0/allure-2.7.0.zip]
(https://dl.bintray.com/qameta/generic/io/qameta/allure/allure/2.7.0/allure-2.7.0.zip)

下载好之后,解压到运行pytest的目录下

打开\allure-2.7.0\bin文件夹,会看到allure.bat文件,讲此路径设置为系统环境变量path下,这样cmd任意目录都能执行了

比如我的路径:D:\YOYO\case\allure-2.7.0\bin

运行allure2

前面pytest -s -q —alluredir 这一步已经生产了xml格式的报告,放到了report目录下,接着执行以下命令格式

allure generate directory-with-results/ -o directory-with-report

directory-with-results是alluredir生成的xml目录,directory-with-report是最终生成html的目录

allure.bat已经加到环境变量了,所以可以用相对路径去生成html报告

allure generate report/ -o report/html

执行完之后目录结构如下:

打开报告

直接找到report/html打开index.html会显示一个空的报告,这里用pycharm去打开

打开后报告展示

依赖java环境

allure2是java开发的,需要依赖java环境,jdk版本用1.8就可以了

### ** 作者:上海-悠悠 QQ交流群:588402570**

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
超详细的 pytest 教程 (四) 之测试报告篇
pytest文档7-pytest-html生成html报告
allure 这么高大上的测试报告环境,5 分钟搞定
聚焦于任务调度的测试平台pytestx
pytest入门 -3
Jenkins构建后展示Allure测试报告
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服