定制自动化pytest框架+allure报告

在自动化测试中,基本都需要使用到pytest框架来管理我们的用例,使用allure框架来生成报告。今天就和大家分享一下这方面的知识,跟着步骤走起来~~~

pytest框架

1、pytest命名规范

pytest测试文件必须以test_开头,或以 _test结尾

测试类必须以Test开头,并且类中不能有init方法

测试方法必须以test开头

断言必须使用assert

2、数据驱动

@pytest.mark.parametrize装饰器可以让测试数据参数化,实现数据驱动,方便代码和测试数据分离

3、多重断言

python 复制代码
pip install pytest-assume

4、生成allure报告

python 复制代码
pip install allure-pytest

allure.zip包解压到某个盘符下即可,并配置环境变量

在cmd命令窗口敲

生成allure报告的命令

5、allure的层级

@allure.epic()第一层 表示项目或应用的范围

@allure.feature()第二层 表示功能或模块

@allure.story()第三层 表示测试主题

@allure.title()第四层 表示具体的测试步骤

6、用例步骤

7、用例的严重等级

severity()

以上就是pytest框架+allure报告具体操作步骤,看完文章就跟着练起来吧!

相关推荐
花酒锄作田5 小时前
Postgres - Listen/Notify构建轻量级发布订阅系统
python·postgresql
Thomas.Sir5 小时前
第二章:LlamaIndex 的基本概念
人工智能·python·ai·llama·llamaindex
m0_694845576 小时前
Dify部署教程:从AI原型到生产系统的一站式方案
服务器·人工智能·python·数据分析·开源
李昊哲小课7 小时前
Python办公自动化教程 - 第7章 综合实战案例 - 企业销售管理系统
开发语言·python·数据分析·excel·数据可视化·openpyxl
不知名的老吴8 小时前
返回None还是空集合?防御式编程的关键细节
开发语言·python
李昊哲小课8 小时前
Python办公自动化教程 - 第5章 图表创建 - 让数据可视化
python·信息可视化·数据分析·数据可视化·openpyxl
chushiyunen8 小时前
python pygame实现贪食蛇
开发语言·python·pygame
Dream of maid8 小时前
Python-基础2(流程控制)
python
Lenyiin9 小时前
《Python 修炼全景指南:一》从环境搭建到第一个程序
开发语言·python
涛声依旧3931610 小时前
Python项目实战:学生信息管理系统
开发语言·python·数据挖掘