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

相关推荐
程序员小远8 小时前
Pytest+Selenium UI自动化测试实战实例
自动化测试·软件测试·python·selenium·测试工具·ui·pytest
惜.己2 天前
pytest简单使用和生成测试报告
开发语言·python·pytest
better-tomorrow2 天前
pytest-log
pytest
别在内卷了5 天前
测试学习之——Pytest Day4
python·学习·pytest
别在内卷了6 天前
测试学习之——Pytest Day3
python·学习·pytest
土小帽软件测试7 天前
mac系统安装、启动Jenkins,创建pytest接口自动化任务
macos·jenkins·pytest
Chasing__Dreams7 天前
pytest--1--pytest-mock常用的方法
pytest
chao_7898 天前
更灵活方便的初始化、清除方法——fixture【pytest】
服务器·自动化测试·python·pytest
别在内卷了9 天前
测试学习之——Pytest Day2
服务器·学习·pytest
chao_78910 天前
pytest 实战演练【pytest】
自动化测试·单元测试·自动化·pytest