pytest + allure 生成测试报告

pytest测试样例规则:
测试文件以test_开头(以_test结尾也可以)
测试类以Test开头,并且不能带有 init 方法
测试函数以test_开头
断言使用基本的assert即可

ubuntu 安装allure
sudo apt-add-repository ppa:qameta/allure
sudo apt-get update
sudo apt-get install allure

mac安装allure:
brew install allure

源码安装参考地址:
https://bintray.com/qameta/generic/allure2

安装pytest以及allure包:
pip3 install pytest
#不使用这个pip3 install pytest-allure-adaptor,用下面那个
pip3 install allure-pytest

创建一个用例
test_one.py:

class TestClassOne(object):
def test_one(self):
x = "this"
assert ‘t‘in x
def test_two(self):
x = "hello"
assert hasattr(x, ‘check‘)

class TestClassTwo(object):
def test_one(self):
x = "iphone"
assert ‘p‘in x
def test_two(self):
x = "apple"
assert hasattr(x, ‘check‘)

#执行所有用例文件
pytest --alluredir=report
allure generate report

#执行指定用例文件
pytest -s -q --alluredir=report test_one.py
allure generate report

覆盖生成报告
#allure generate report --clean

执行完testcase后,生成报告,模版在 allure-report 中,将index.html在服务器环境中打开。

默认情况下,report目录中的json文件是累加的,不会清除,如果需要重新跑一遍用例,那么应该先清空report文件夹,再执行上面的命令,即可显示本次执行结果。

原文地址:https://www.cnblogs.com/sea-stream/p/11384574.html

时间: 2024-08-30 12:31:27

pytest + allure 生成测试报告的相关文章

用Pytest+Allure生成漂亮的HTML图形化测试报告

本篇文章将介绍如何使用开源的测试报告生成框架Allure生成规范.格式统一.美观的测试报告. 通过这篇文章的介绍,你将能够: - 将Allure与Pytest测试框架相结合: - 执行测试之后,生成Allure格式的测试报告. 1.Allure测试报告介绍 Allure是一款非常轻量级并且非常灵活的开源测试报告生成框架. 它支持绝大多数测试框架, 例如TestNG.Pytest.JUint等.它简单易用,易于集成.下面就Pytest如何与Allure集成做详细介绍. 2.Pytest框架集成Al

Pytest集成Allure生成测试报告

Pytest集成Allure生成测试报告 1.Allure安装 1)Allure报告的demo样式(是不是很漂亮呢) 2)Allure下载 选择需要的版本,下载zip文件,解压即可 2.添加allure环境变量 path:D:\Program Files\allure-2.13.1\bin 3.查看生成的allure报告 cmd:allure serve allure生成的报告路径 启动后会自动跳转到 http://192.168.11.1:54011/ 打开测试报告 4.pytest中集成al

python学习-pytest(四)-Pytest集成Allure生成测试报告

Pytest集成Allure生成测试报告 1.Allure安装 1)Allure报告的demo样式(是不是很漂亮呢) 2)Allure下载 选择需要的版本,下载zip文件,解压即可 2.添加allure环境变量 path:D:\Program Files\allure-2.13.1\bin 3.查看生成的allure报告 1. 生成allure报告 # 要先进入到allure生成的报告文件夹上级目录 cmd:allure serve allure生成的报告文件夹 启动后会自动跳转到 http:/

python + allure生成测试报告

首先我们需要在python环境上安装pytest库,这里建议通过pip安装:pip install pytest 然后编写一个简单的pytest测试用例,这里我们需要满足以下条件 测试文件以test_开头(以_test结尾也可以) 测试类以Test开头,并且不能带有 init 方法 测试函数以test_开头 断言使用基本的assert即可 编写简单代码如下,test_sample.py import pytest class TestClass(object): @pytest.fixture(

Python单元测试框架之pytest -- 生成测试报告

继续pytest单元测试框架的学习,pytest可以生成多种类型的测试报告.这一节就来学习pytest如何生成测试报告. 创建test_calss.py 测试用例文件,这里以测试该文件为例. #coding=utf-8 class TestClass: def test_one(self): x = "this" assert "h" in x def test_two(self): x = "hello" assert x == "h

Allure+pytest 生成测试报告

简介: python 主流自动化测试报告插件有三个:HTMLTestRunner.BeautifulReport 和 Allure.HTMLTestRunner是一个比较古老的报告模板,界面也不是很好看.BeautifulReport  界面很简洁,看起来也很直观,是一款比较不错的报告插件.如果你想提升一下你的level,让你的自动化测试报告变得高大上,那么请选择 Allure . Allure 是一款轻量级的开源自动化测试报告生成框架.它支持绝大部分测试框架,比如 TestNG.Junit .

pytest+allure(allure-pytest基于这个插件)生成漂亮的报告+显示

一:环境准备 1.python3.6 2.windows环境 3.pycharm 4.allure-pytest 5.allure2.8.0 6.java1.8 allure-pytest快速安装 在cmd中输入 pip install allure-pytest,回车 二:报告生成 第1步:下载allure.zip,下载地址:allure-github: https://github.com/allure-framework/allure2 ,找到对应版本,并下载 第2步:解压allure.z

Pytest+Allure环境的搭建

参考博客 1. pytest的安装: 1.1. windows下: pip install pytest 1.2. linux下: pip install pytest 2. 安装pytest-allure-adaptor插件 2.1. windows下: pip install pytest-allure-adaptor 3. allure的安装: 3.1. windows下: 前情提示: allure是基于Java的一个程序,需要Java1.8的环境,没有安装需要去安装一下. Windows

Allure自动化测试报告我是这样用的

关于自动化测试报告: 之前用过testNG自带的测试报告.优化过reportNG的测试报告.extentreport.Zreport(大飞总原创),这些是我之前都用过的,也是在去年雯姐和我说过Allure2这个报告不错,一直没时间,正巧最近有用到,接触下发现确实是个神器. Allure(已经有allure2了,小编用的就是allure2),生成的测试报告与上述对比,简直堪称完美!先上个测试报告的图表,给大家直观感受下: 下面让我们一起走进Allure的世界,跟上步伐,相信我这一切并不难 一.po