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

相关推荐
bjwuzh2 天前
使用pytest实现参数化后,控制台输出的日志是乱码
pytest
2025年一定要上岸3 天前
pytest框架 - 第二集 allure报告
pytest
头疼的程序员4 天前
allure生成测试报告(搭配Pytest、allure-pytest)
测试工具·pytest
文人sec4 天前
接口自动化测试设计思路--设计实战
python·https·单元测试·自动化·pytest
测试开发Kevin6 天前
从投入产出、效率、上手难易度等角度综合对比 pytest 和 unittest 框架
python·pytest
测试开发Kevin8 天前
以pytest_addoption 为例,讲解pytest框架中钩子函数的应用
python·pytest
川石教育14 天前
Pytest中的fixture装饰器详解
python自动化测试·pytest·pytest自动化测试框架·pytest测试框架·pytest单元测试框架
春风又。14 天前
接口自动化——参数化
python·测试工具·自动化·pytest
XTY0016 天前
mac电脑pytest生成测试报告
pytest
程序员的世界你不懂17 天前
pytest-前后置及fixture运用
pytest