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

环境准备

  • 1.python3.6

  • 2.mac环境

  • 3.pycharm

  • 4.pytest-allure-adaptor

  • 5.allure2.8.0

  • 6.java1.8或者1.8以上

Allure Pytest Adaptor是Pytest的一个插件,通过它我们可以生成Allure所需要的用于生成测试报告的数据。安装pytest-allure-adaptor插件方法

1.下载和安装命令:

pip3 install pytest-allure-adaptor

首先需要安装命令行工具,如果是Mac电脑,推荐使用Homebrew安装。

$ brew install allure

2.生成xml报告:

pytest -s -q —alluredir report

如果不指定路径,默认在当前目录下新建一个report目录,当然也可以指定路径   ($ pytest -s -1q --alluredir ./result/)

pytest -s -q —alluredir 指定report路径

执行完之后打开report文件夹,会自动生成xml格式的报告

我的在 /Users/newcomer/gitByMyself/python_work_apple/pytest_package/demo 目录下执行的

首先:

cd /Users/newcomer/gitByMyself/python_work_apple/pytest_package/demo

然后:

pytest -s -q --alluredir report

这一步已经生产了xml格式的报告,放到了report目录下:

3.运行allure2

按照这样的格式:allure generate directory-with-results/ -o directory-with-report。directory-with-results是alluredir生成的xml目录,directory-with-report是最终生成html的目录(allure generate ./result/ -o ./report/ --clean),可以用相对路径去生成html报告

allure generate report/ -o report/html --clean

这样在./report/目录下就生成了Allure的测试报告了。–clean目的是先清空测试报告目录,再生成新的测试报告。打开的时候在pycharm里面打开,这样的页面就不会是空的了

第一个report(因为设置的目录名字叫report)是alluredir生成的xml目录,第二个report是最终生成html的目录

还可以通过下面的命令打开测试报告:

--------------------------------------------------------------------------------------------------------

$ allure open -h 127.0.0.1 -p 8083 ./report/
------------------------------------------------------------------------------------------------------------------------


pytest 11 allure2生成html报告的更多相关文章

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

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

  2. pytest(11)-Allure生成测试报告(一)

    Allure是一个开源的测试报告生成框架,提供了测试报告定制化功能,相较于我们之前使用过pytest-html插件生成的html格式的测试报告,通过Allure生成的报告更加规范.清晰.美观. pyt ...

  3. allure2生成html报告

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

  4. 使用allure2生成精美报告

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

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

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

  6. 手把手教你Pytest+Allure2.X定制报告详细教程,给自己的项目量身打造一套测试报告-02(非常详细,非常实用)

    简介 前边一篇文章是分享如何搭建pytest+Allure的环境,从而生成一份精美的.让人耳目一新的测试报告,但是有的小伙伴或者童鞋们可能会问,我能不能按照自己的想法为我的项目测试结果量身打造一份属于 ...

  7. 【Mac+Wind7】pytest + allure生成定制报告

    一.升级Powershell(windows7及以上版本默认自带.其实普通的CMD命令行工具够用了) 我是Win7默认带的pw1.0,太古老了升级一下,地址如下,选择与自己windows版本匹配的连接 ...

  8. pytest 6 生成html报告

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

  9. pytest十五:pytest-html 生成 html 报告

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

随机推荐

  1. 谈谈你对this对象的理解

    理解: 1.this是js 的一个关键字,随着函数的使用场合的不同,this 的值会发生变化. 2.一个总原则:即this指的是调用函数的那个对象. 3.一般情况下,this 是全局对象,可以作为方法 ...

  2. 【原】Java学习笔记025 - 内部类

    package cn.temptation; public class Sample01 { public static void main(String[] args) { // 内部类(嵌套类): ...

  3. Docker(1):CentOS7 安装Docker

    1.查看系统内核,docker要求系统的内核版本高于3.10 #  uname -r 2.升级yum包,确保最新 #   yum update 3.安装所需要依赖包 #   yum install - ...

  4. 如何在本地搭建DVWA环境

    如何在本地搭建DVWA环境 1.工具下载:  (1)phpStudy:   http://phpstudy.php.cn/download.html (2)DVWA:http://www.dvwa.c ...

  5. Jetson TX2(2)ubutu1604--安装opencv3.4.0

    1安装OpenCV3.4.0+contrib 1 在终端中敲入以下两句sudo rm /var/cache/apt/archives/locksudo rm /var/lib/dpkg/lock su ...

  6. spring boot拦截器WebMvcConfigurerAdapter,以及高版本的替换方案(转)

    文章转自 http://blog.51cto.com/12066352/2093750 最近项目采用spring icloud,用的spring boot版本是1.5.x的,spring boot 2 ...

  7. (十三)Batch Processing

    In addition to being able to index, update, and delete individual documents, Elasticsearch also prov ...

  8. 在Fabric ChainCode中导入第三方包(以状态机为例)

    在企业级应用开发中,经常会涉及到流程和状态,而有限状态机(FSM)则是对应的一种简单实现,如果复杂化,就上升到Workflow和BPM了.我们在Fabric ChainCode的开发过程中,也很可能涉 ...

  9. 关于Jpa和Mybatis的一些看法

    现在网络上充斥着Jpa和Mybatis的一些对比.其实狭义上来说是hibernate和mybatis之间的比较. 例如:为什么感觉国内比较流行的 mybatis 在国外好像没人用的样子? 下面是一些截 ...

  10. Flask Session 使用和源码分析 —— (6)

    基本使用 from flask import Flask, session, redirect, url_for, escape, request app = Flask(__name__) @app ...