前言

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报告(史上最详细)的更多相关文章

  1. pytest十六:allure2 生成 html 报告

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

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

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

  3. pytest文档3-pycharm运行pytest

    前言 上一篇pytest文档2-用例运行规则已经介绍了如何在cmd执行pytest用例,平常我们写代码在pycharm比较多 写完用例之后,需要调试看看,是不是能正常运行,如果每次跑去cmd执行,太麻 ...

  4. pytest文档8-参数化(parametrize)结合allure.title()生成不同标题报告

    参数化parametrize 先看一个简单的pytest参数化案例演示test_a.py # test_a.py import pytest import allure def login(usern ...

  5. pytest 11 allure2生成html报告

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

  6. pytest文档20-pytest-html报告优化(添加Description)

    前言 pytest-html测试报告默认是不展示用例描述Description内容,之前用unittest生成的报告是可以展示用例的描述,也就是test开头的用例下三个引号里面的注释(docstrin ...

  7. pytest文档21-pytest-html报告优化(nodeid中文显示[\u6350\u52a9\u6211\u4eec]问题解决)

    前言 pytest-html报告中当用到参数化时候,获取用例的nodeid里面有中文时候,会显示[\u6350\u52a9\u6211\u4eec]这种编码(再次声明,这个不叫乱码,这是unicode ...

  8. pytest文档1-环境准备与入门

    前言 首先说下为什么要学pytest,在此之前相信大家已经掌握了python里面的unittest单元测试框架,那再学一个框架肯定是需要学习时间成本的. 刚开始我的内心是拒绝的,我想我用unittes ...

  9. pytest文档29-allure-pytest(最新最全,保证能搞成功!)

    前言 之前写了个pytest的allure相关的教程,只是停留在环境搭建完成,后续一直没用,小编一直不喜欢这种花里胡哨的报告. 没办法,领导就喜欢这种,小伙伴们也喜欢,所以还是得把allure用起来, ...

随机推荐

  1. Codeforces 584E - Anton and Ira - [贪心]

    题目链接:https://codeforces.com/contest/584/problem/E 题意: 给两个 $1 \sim n$ 的排列 $p,s$,交换 $p_i,p_j$ 两个元素需要花费 ...

  2. emcc,wasm,webassembly

    WASM: https://github.com/Hanks10100/wasm-examples/tree/master/simple mkdir hello cd hello echo '#inc ...

  3. DELPHI中完成端口(IOCP)的简单分析(2)

    DELPHI中完成端口(IOCP)的简单分析(2)   今天我写一下关于DELPHI编写完成端口(IOCP)的工作者线程中的东西.希望各位能提出批评意见.上次我写了关于常见IOCP的代码,对于IOCP ...

  4. RoR - Expressing Database Relationships

    One-to-One Association: *一个person只对应一个personal_info *一个personal_info只属于一个person *belongs to用foreign ...

  5. ES6 数值

    数值的表示 二进制表示法新写法: 前缀 0b 或 0B . console.log(0b11 === 3); // true console.log(0B11 === 3); // true 八进制表 ...

  6. 解决web资源跨域请求问题

    参考地址: http://my.oschina.net/lichaoqiang/blog/317823 在浏览器请求中,出现跨域访问资源的问题,我们肯定会遇到.如果跨域请求被阻止,有可能导致css.j ...

  7. 网络视频播放ZFPlayer

    根据项目需要,公司app需要用到视频播放功能,推荐ZFPlayer,视频播放几乎有你想要的任何样式,该博客只是为了给自己留一个以后查找的资料, 改代码可以使用ZFPlayer github地址 htt ...

  8. 对Java代码加密的两种方式,防止反编译

    使用Virbox Protector对Java项目加密有两种方式,一种是对War包加密,一种是对Jar包加密.Virbox Protector支持这两种文件格式加密,可以加密用于解析class文件的j ...

  9. Docker:Docker搭建Redis集群(6)

    国外的公有云实在是太慢了,经常time out 这里搜集几个国内出名的: hub.c.163.com (网易:https://c.163.com/hub#/m/home/) dev.aliyun.co ...

  10. IdentityServer4授权和认证对接数据库

    接着上一篇讲:https://www.cnblogs.com/nsky/p/10352678.html 我们之前都是用in-men的方式把数据添加到内存了,目的是为了测试方便, 现在我们把所有配置都添 ...