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

上海-悠悠      2022-02-14     131

关键词:

前言

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

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

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环境

之前用的jdk1.7版本,执行allure时候报错:Unsupported major.minor VERSION 51.0
由于allure2是java开发的,需要依赖java环境,解决办法:jdk版本用1.8就可以了
---------------------------------pytest结合selenium自动化完整版-------------------------

全书购买地址 https://yuedu.baidu.com/ebook/902224ab27fff705cc1755270722192e4536582b

作者:上海-悠悠 QQ交流群:874033608

也可以关注下我的个人公众号:yoyoketang

pytest框架生成pytest-html报告

   需要安装pytest-html插件;pipinstallpytest-htmlpytest可以生成多种样式的结果:生成JunitXML格式的测试报告,命令:--junitxml=path生成ResultLog格式的测试报告,命令:--resultlog=report/log.txt生成Html格式的测试报告,命令:--html=OutPuts... 查看详情

pytest6生成html报告

前言:pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告。兼容Python2.7,3.61.github上源码地址【https://github.com/pytest-dev/pytest-html】2.pip安装  pipinstallpytest-html3.执行方法  pytest--html=report.htmlhtml报告1.打开cmd,cd到需要执行pyte 查看详情

pytest学习和使用16-html报告如何生成?(pytest-html)(代码片段)

16-HTML报告如何生成?(pytest-html)1插件介绍2pytest-html安装3生成报告3.1插件执行方式3.2执行效果3.3指定报告生成的路径4合并css5报告中的行显示设置6报告增强6.1自定义css6.2报告标题6.3环境6.4其他摘要信息6.5Extra内容6.6... 查看详情

pytest文档75-生成junit-xml测试报告(代码片段)

前言pytest生成junit-xml测试报告,那么生成的xml报告有什么用呢?可以集合一些持续集成工具(如jenkins…等)方便查看报告。junit-xml测试报告命令行参数有2个跟junit-xml报告相关的参数--junit-xml=pathcreatejunit-xmlstyler... 查看详情

pytest执行并生成报告方式

pytest自带报告pytest可以生成junit格式的xml报告和HTML报告,命令如下:pytesttest_demo.py--junitxml=report.xmlpytesttest_demo.py--html=report.html#需要安装插件:pipinstallpytest-html然后在同目录下生成了report.html文件,打开如下:alluer报告界面看着不... 查看详情

pytest.main无法生成报告pytest-html报告,cmd可以?

我在cmd可以正常生成pytest-html报告,但是在pycharm里面,用pytest的main函数却无法生成。cmd命令:首先进入py文件的项目录通过cd命令,最后执行pytesttest_login2.py--html=./report/report2.html能正常生成pycharm命令:无法生成if__name__=='... 查看详情

pytest系列(12)-测试结果生成html报告插件之pytest-html的详细使用

如果你还想从头学起Pytest,可以看看这个系列的文章哦!https://www.cnblogs.com/poloyy/category/1690628.html 环境前提Python3.6+ 安装插件pip3installpytest-html-ihttp://pypi.douban.com/simple/--trusted-hostpypi.douban.com  查看详情

pytest文档78-钩子函数pytest_runtest_makereport获取用例执行报错内容和print内容(代码片段)

前言pytest在执行用例的时候,当用例报错的时候,如何获取到报错的完整内容呢?当用例有print()打印的时候,如何获取到打印的内容?钩子函数pytest_runtest_makereport测试用例如下,参数化第一个用例成功... 查看详情

pytest_allure2生成html报告

pip安装pytest-allure-adaptor,github地址 https://github.com/allure-framework/allure-pytestpip3installpytest-allure-adaptor/python3-mpipinstallpytest-allure-adaptor 生成xml报告pytest-s-q--alluredirrep 查看详情

pytest测试报告美化

参考技术Apytest-HTML是一个插件,pytest用于生成测试结果的HTML报告。兼容Python2.7,3.6安装方式:pipinstallpytest-html然后写一个测试类在命令行中执行:如下:在当前目录下可以看到生成了一个report.html的文件,点开就可以看到测试报... 查看详情

用pytest+allure生成漂亮的html图形化测试报告

...。 通过这篇文章的介绍,你将能够: -将Allure与Pytest测试框架相结合; -执行测试之后,生成Allure格式的测试报告。1、Allure测试报告介绍Allure是一款非常轻量级并且非常灵活的开源测试报告生成框架。它支持绝大多数... 查看详情

pytest两种生成测试报告的方法——html(代码片段)

pytest有两种生成测试报告的方法(html和allure),今天就给大家一介绍下html一.pytest-html基本语法1.安装:pipinstallpytest-html2.查看版本:pipshowpytest-html3.生成测试报告基本语法:语法一:pytest--html=生成报... 查看详情

pytest生成测试报告

生成JunitXML格式的测试报告   --junitxml=report\\h.xml  生成resultlog格式的测试报告   --resultlog=report\\h.log  生成html格式的测试报告   --html=report\\h.html&nbs 查看详情

pytest生成测试报告(代码片段)

pip安装pipinstallpytest-html编写脚本importpytestclassTestClass(object):deftest_one(self):x="this"assert‘h‘inxdeftest_two(self):x="hello"assert‘h‘inx运行程序:pytest--html=report.html结果:C:UsershaiyDesktopcode 查看详情

pytest结合allure生成测试报告

#官方文档:   https://docs.qameta.io/allure/#_installing_a_commandline 引用官方文档中的话:Allure框架是一个灵活的轻量级多语言测试报告工具,它不仅以web的方式展示了简介的测试结果,而且允许参与开发过程的每个人从日... 查看详情

pytest文档81-如何管理capturedlogging日志(代码片段)

前言pytest自动捕获级别为WARNING或以上的日志消息,并以与捕获的stdout和stderr相同的方式在每个失败测试的各自部分中显示它们。日志显示当输入pytest命令,不带任何参数时pytest如果运行的用例没有报错,那么打印的... 查看详情

pytest基础(代码片段)

文章目录一、pytest简介二、基本功能三、运行一、pytest简介Pytest是一个测试框架,其将测试常用的内容都包含进来了,如生成测试报告、生成覆盖率报告等。而且Pytest提供插件功能,很多开发人员可以通过开发Pytest插件来扩展Pyt... 查看详情

pytest基础特性02

参考技术Apytest-html           生成html格式的自动化测试报告pytest-xdist           测试用例分布式执行,多cpu分发pytest-ordering      ... 查看详情