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 任意目录都能执行了


运行 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 环境  (搭建java环境自行百度)
之前用的 jdk1.7 版本,执行 allure 时候报错:Unsupported major.minor VERSION 51.0
由于 allure2 是 java 开发的,需要依赖 java 环境,解决办法:jdk 版本用 1.8 就可以了 如果前学过 unittest 框架的应该知道,unittest 框架用个痛点,用例不用例之间的独立的,不能跨脚本运行数据共享。比如 test_01.py的 driver,不能共享到 test_02.py 上。这样会导致一个问题,每次运行一个.py 的脚本用例,会重复打开浏览器,浪费比较多的时间。 pytest 框架就能很好的解决这个问题,只需在 conftest.py 设置一个前置的 fixture 功能,设置为 session 级别,返样所有的用例之间都能共享 driver 了。

pytest十六:allure2 生成 html 报告的更多相关文章

  1. pytest 11 allure2生成html报告

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

  2. Pytest学习(十二)-生成HTML报告插件之pytest-html的使用

    环境前提 Python3.6+ 安装插件 pip3 install pytest-html -i http://pypi.douban.com/simple/ --trusted-host pypi. ...

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

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

  4. pytest文档7-pytest-html生成html报告

    前言 pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告.兼容Python 2.7,3.6 pytest-html 1.github上源码地址[https://github. ...

  5. jmeter(二十六)生成HTML性能测试报告

    性能测试工具Jmeter由于其体积小.使用方便.学习成本低等原因,在现在的性能测试过程中,使用率越来越高,但其本身也有一定的缺点,比如提供的测试结果可视化做的很一般. 不过从3.0版本开始,jmete ...

  6. allure2生成html报告

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

  7. 使用allure2生成精美报告

    安装:brew install allure pip install allure-pytest 在测试执行期间收集结果 pytest -s –q --alluredir=./result/ 测试完成 ...

  8. Wix 安装部署教程(十六) -- 自动生成多语言文件

    因为持续集成需要,所有项目编译完之后生成一个多语言的安装包.之前生成mst文件都是手动操作,而且mst文件必须每次重新和新的安装包“关联”,否则中文的安装包去调用英文的资源的时候就会报类似于“类型转换 ...

  9. 深度学习(六十六)生成模型、最大化似然、KL散度

随机推荐

  1. python---redis缓存页面前戏之剖析render源码

    1.初始代码: def get(self, *args, **kwargs): import time tm = time.time() self.render('home/index.html', ...

  2. centos7下安装redis的步骤

    原贴地址:https://www.cnblogs.com/zuidongfeng/p/8032505.html 我linux服务器上是这样启动的: cd /tool/redis/redis-3.2.8 ...

  3. JAVA记录-WebService开发部署

    JWS.Axis2.cxf 1.下载axis2.war和axis2.bin.zip 2.将axis2.war包部署到Tomcat下,启动Tomcat测试:http://localhost:8089/a ...

  4. linq to xml 简单的增、删、改、查、保存xml文件操作

    using System; using System.Collections; using System.Configuration; using System.Data; using System. ...

  5. dubbo集群服务下一台服务挂了对服务调用的影响

    一.问题描述:项目中2台dubbo服务给移动端提供查询接口,移动端反应说查询时而很快(秒刷),时而很慢(4-5秒). 二.问题分析: 1.问题猜想:网络不稳定原因导致,但是切换公司wifi和手机4G, ...

  6. Spring源码学习资料

    未完待续.. github地址 https://github.com/spring-projects 学习地址 https://github.com/code4craft/tiny-spring 推荐 ...

  7. android logger 日志工具

    https://github.com/orhanobut/logger 基础使用:https://blog.csdn.net/github_33304260/article/details/54799 ...

  8. 【CXF】: No binding operation info while invoking unknown method with params unknown.

    CXF发布webservice之后访问报错: org.apache.cxf.interceptor.Fault: No binding operation info while invoking un ...

  9. oracle新建对象 权限管理

    代码 CREATE USER target IDENTIFIED BY target ; GRANT CONNECT, RESOURCE TO target; 刚刚创建的oracle实例中会内建两个用 ...

  10. 解决Centos下yum无法更新

    问题: http://mirrors.cloud.aliyuncs.com/epel/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - ...