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

相关推荐
唐古乌梁海4 小时前
【pytest】编写自动化测试用例命名规范README
自动化·pytest
xing25165 小时前
pytest下allure
开发语言·python·pytest
IT求学人1 天前
pytest运行用例的常见方式及参数
pytest
开源优测2 天前
什么是pytest.ini及如何在Pytest中应用以提升配置效率
pytest
摸鱼仙人~3 天前
ImportError: cannot import name ‘FixtureDef‘ from ‘pytest‘
conda·pytest·fastapi
唐古乌梁海3 天前
【pytest-jira】自动化用例结合jira初版集成思路
pytest·jira
小码哥说测试5 天前
高效执行自动化用例:分布式执行工具pytest-xdist实战!
自动化测试·软件测试·功能测试·jmeter·pytest·postman·测试工程师
予早5 天前
pytest asyncio 支持插件 pytest-asyncio
pytest