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
** 作者:上海-悠悠 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文档13-allure2生成html报告(史上最详细)的更多相关文章
- pytest十六:allure2 生成 html 报告
allure 是一个 report 框架,支持 java 的 Junit/testng 等框架,当然也可以支持 python 的 pytest 框架,也可以集成到 Jenkins 上展示高大上的报告界 ...
- pytest文档7-pytest-html生成html报告
前言 pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告.兼容Python 2.7,3.6 pytest-html 1.github上源码地址[https://github. ...
- pytest文档3-pycharm运行pytest
前言 上一篇pytest文档2-用例运行规则已经介绍了如何在cmd执行pytest用例,平常我们写代码在pycharm比较多 写完用例之后,需要调试看看,是不是能正常运行,如果每次跑去cmd执行,太麻 ...
- pytest文档8-参数化(parametrize)结合allure.title()生成不同标题报告
参数化parametrize 先看一个简单的pytest参数化案例演示test_a.py # test_a.py import pytest import allure def login(usern ...
- pytest 11 allure2生成html报告
allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 1.pyt ...
- pytest文档20-pytest-html报告优化(添加Description)
前言 pytest-html测试报告默认是不展示用例描述Description内容,之前用unittest生成的报告是可以展示用例的描述,也就是test开头的用例下三个引号里面的注释(docstrin ...
- pytest文档21-pytest-html报告优化(nodeid中文显示[\u6350\u52a9\u6211\u4eec]问题解决)
前言 pytest-html报告中当用到参数化时候,获取用例的nodeid里面有中文时候,会显示[\u6350\u52a9\u6211\u4eec]这种编码(再次声明,这个不叫乱码,这是unicode ...
- pytest文档1-环境准备与入门
前言 首先说下为什么要学pytest,在此之前相信大家已经掌握了python里面的unittest单元测试框架,那再学一个框架肯定是需要学习时间成本的. 刚开始我的内心是拒绝的,我想我用unittes ...
- pytest文档29-allure-pytest(最新最全,保证能搞成功!)
前言 之前写了个pytest的allure相关的教程,只是停留在环境搭建完成,后续一直没用,小编一直不喜欢这种花里胡哨的报告. 没办法,领导就喜欢这种,小伙伴们也喜欢,所以还是得把allure用起来, ...
随机推荐
- IBM Installation Manager 工具概述(转)
IBM Installation Manager 工具概述 IBM Installation Manager 是一款可运行在多种平台(如 IBM i. z/OS. Windows. Linux.Uni ...
- linux 系统下apache 找不到apxs 文件
yum install httpd-devel
- (二)juc线程高级特性——CountDownLatch / Callable / Lock
5. CountDownLatch 闭锁 Java 5.0 在 java.util.concurrent 包中提供了多种并发容器类来改进同步容器的性能. CountDownLatch 一个同步辅助类, ...
- LeetCode 206 Reverse Linked List 解题报告
题目要求 Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5-> ...
- Docker入门6------生产力工具rancher
rancher的安装: https://blog.csdn.net/wh211212/article/details/80932264 安装 一行命令就可以安装 sudo docker run -d ...
- Fernflower 反编译.class文件
最近有些奇怪Intellij IDEA通过什么查看的源码,通过打开源码意外的发现如下注释 原来是通过Fernflower这个反编译工具w(゚Д゚)w. 使用Fernflower反编译出的代码相当友好, ...
- i++与++i区别
++i:先执行i加1,再执行语句; i++:先执行语句,再i加1; 后置自操作:先把自己所保存的值留下来,然后改变自己,自己给别人的值是原来的值: 前置自操作:先把自己改变,然后把改变后的值给别人. ...
- python+requests+excel+unittest+ddt接口自动化数据驱动并生成html报告
1.环境准备: python3.6 requests xlrd openpyxl HTMLTestRunner_api 2.目前实现的功能: 封装requests请求方法 在excel填写接口请求参数 ...
- nrm 使用
全局安装 npm i nrm -g 全局安装nrm nrm ls 查看镜像地址: npm ---- https://registry.npmjs.org/ cnpm --- http://r.c ...
- JavaScript 原型链学习(一)原型对象
在JavaScript中创建的每个函数都有一个prototype(原型)属性,这个属性是一个指针,指向一个对象,而这个对象的用途是包含可以由特定类型的所有的实例共享的属性和方法.如果按照字面意思来理解 ...