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描述,展示执行步骤的含义,既可以向项目干系人体现测试思路,又可以在测试出问题后清晰向他人描述问题。

相关推荐
小熊出擊6 小时前
【pytest】fixture 内省(Introspection)测试上下文
python·单元测试·pytest
小熊出擊1 天前
【pytest】finalizer 执行顺序:FILO 原则
python·测试工具·单元测试·pytest
小熊出擊2 天前
【pytest】使用 marker 向 fixture 传递数据
python·pytest
wa的一声哭了3 天前
Deep Learning Optimizer | Adam、AdamW
人工智能·深度学习·神经网络·机器学习·自然语言处理·transformer·pytest
专职4 天前
pytest生成测试用例,allure生成测试报告
测试用例·pytest
小丁爱养花8 天前
接口自动化测试 - pytest [1]
python·自动化·pytest
向上的车轮9 天前
如何用AI工具开发一个轻量化CRM系统(七):AI生成pytest测试脚本
pytest
慌糖9 天前
自动化接口框架搭建分享-pytest第三部分
运维·自动化·pytest
Script kid9 天前
Pytest框架速成
数据库·pytest
小熊出擊9 天前
[pytest] 一文掌握 fixture 的作用域(scope)机制
python·功能测试·单元测试·自动化·pytest