定制自动化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 小时前
[Python] 从《千字文》中随机挑选汉字
后端·python
cup119 小时前
[技术复盘] Windows Python 打包实战:Nuitka 环境踩坑总结与 CI 自动化构建全指南
python·ai·环境变量·ci·nuitka·skill
aqi0011 小时前
15天学会AI应用开发(七)有了大模型为什么还要引入RAG
人工智能·python·大模型·ai编程·ai应用
金銀銅鐵13 小时前
用 Python 实现 Take-Away 游戏
python·游戏
copyer_xyf14 小时前
Agent 流程编排
后端·python·agent
copyer_xyf15 小时前
Agent RAG
后端·python·agent
copyer_xyf15 小时前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf15 小时前
Agent 记忆管理
后端·python·agent
星云穿梭1 天前
用Python写一个带图形界面的学生管理系统——完整教程
python