前言

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. 怎样把Word文档导入Excel表格

    Word是现在办公中的基础文件格式了,很多的内容我们都通过Word来进行编辑,那么当我们需要将Word文档里的信息导入到Excel里面的时候,我们应该怎样做呢?下面我们就一起来看一下吧. 操作步骤: ...

  2. Luogu 1068 - 分数线划定 - [快速排序]

    题目链接:https://www.luogu.org/problemnew/show/P1068 题目描述世博会志愿者的选拔工作正在 A 市如火如荼的进行.为了选拔最合适的人才,A 市对所有报名的选手 ...

  3. [Database.System.Concepts(6th.Edition.2010)].Abraham.Silberschatz. Ch8学习笔记

    Database Ch8.relational design 8.1 features of good design 8.1.1 larger alternatives why design is g ...

  4. :after和:before 伪类

    1 使用伪类画三角形 .div{ margin-top: 100px; margin-left: 100px; } .div:after{ content: ''; display:inline-bl ...

  5. Windows10远程桌面Ubuntu16.04

    一.Ubuntu16.04端软件安装(管理员权限) 1.安装xrdp sudo apt-get install xrdp 2.安装vnc4server sudo apt-get install vnc ...

  6. 10大必备的Intellij插件,大幅提高你的工作效率

    转自: https://blog.csdn.net/qq1404510094/article/details/80379375 1. .ignore 生成各种ignore文件,一键创建git igno ...

  7. Java加载dll或so库文件的路径 java.library.path

      1. Java的System.load 和 System.loadLibrary都可以用来加载库文件   2.例如你可以这样载入一个windows平台下JNI库文件: System.load(&q ...

  8. vsftp快速搭建ftp服务器

    什么是vsftp: vsftpd 是一个 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux, BSD, Solaris, HP-UX 以及 IRIX 上面.它支持很多其他的 FT ...

  9. Jenkins Pipeline脚本

    node { echo 'Hello World' } node 在Jenkins环境中分配一个执行器和工作空间. echo 在控制台输出中写入简单的字符串 try { timeout(time: 1 ...

  10. ubuntu常用软件命令

    解压zip软件 unzip  xxx.zip -d解压到指定目录 清理磁盘空间 sudo apt-get autoremove sudo apt-get clean sudo dpkg --list ...