26、pytest使用allure解读

官方实例

python 复制代码
# content of pytest_quick_start_test.py
import allure

pytestmark = [allure.epic("My first epic"), allure.feature("Quick start feature")]


@allure.id(1)
@allure.story("Simple story")
@allure.title("test_allure_simple_test displayName")
def test_allure_simple_test():
    with allure.step("Simple step"):
        pass

    with allure.step("Simple parent step"):
        with allure.step("Simple child step"):
            pass

    simple_step_func("function parameter")


@allure.step("Simple function with step decorator")
def simple_step_func(param):
    with allure.step(f"function parameter: {param}"):
        pass
    with allure.step("Simple step inside test function"):
        pass

解读与实操

  1. 运行代码

  2. 生成报告

  1. 查看报告

场景应用

1、allure是定义分类层级,由大到小依次为"epic"(迭代)、"feature"(需求),"story"(场景),"title"(功能点),可以根据实际项目使用全部或部分。仅仅为了进行分类。

2、每个测试用例中增加step描述,展示执行步骤的含义,既可以向项目干系人体现测试思路,又可以在测试出问题后清晰向他人描述问题。

相关推荐
昔时扬尘处12 小时前
【Files Content Replace】文件夹文件内容批量替换自动化测试脚本
c语言·python·pytest·adi
我的xiaodoujiao18 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 32--开源电商商城系统项目实战--如何区分登录状态
python·学习·测试工具·pytest
昔时扬尘处20 小时前
如何检测python和pytest的安装环境
开发语言·python·pytest·自动化测试平台·adi
我的xiaodoujiao21 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 33--基础知识 8--切换窗口句柄
python·学习·测试工具·pytest
cliffordl3 天前
自动化测试(Pytest)
pytest
噔噔噔噔@4 天前
详细介绍Python+Pytest+BDD+Playwright,用FSM打造高效测试框架
开发语言·python·pytest
黑客思维者5 天前
Python自动化测试Pytest/Unittest深度解析与接口测试落地实践
开发语言·python·pytest·unittest
Mr_Xuhhh6 天前
接口自动化测试--requests模块
pytest
19226386 天前
Auto 3: 任意位置多目标点编队控制的分布式控制策略
pytest
我的xiaodoujiao8 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 31--开源电商商城系统项目实战--加入购物车、提交订单测试场景
python·学习·测试工具·pytest