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

相关推荐
2601_962284502 天前
安卓APP UI自动化测试:Python + UiAutomator2 + pytest + pytest-html
python·pytest·uiautomator2·ui自动化测试·安卓app
2601_962300812 天前
基于pytest的接口自动化测试:使用requests模块的实战项目与接口关联方法详解
接口自动化测试·测试用例·pytest·接口关联·requests模块
2601_962300812 天前
Python + Requests + Pytest + Excel + Allure:接口自动化测试项目实战
python·excel·pytest·allure·requests
11路没有终点3 天前
Pytest 安装、版本与第一个测试用例
测试用例·pytest
11路没有终点4 天前
pytest 参数化与 Mark 标记
pytest
2601_962296284 天前
五种Python自动化测试框架汇总,附学习方法
自动化测试·pytest·unittest·robotframework·python框架
11路没有终点5 天前
pytest Fixture 进阶:conftest 与依赖注入
pytest
2601_962387827 天前
web自动化测试实战教程【selenium/unittest/pytest】【共193课
selenium·pytest·devops·web自动化测试·unittest
weixin_440730508 天前
使用pytest中方法控制执行步骤(test_begin.py、test_end.py,@pytest.mark.run(order=1))
开发语言·python·pytest
2601_962297258 天前
Python、Pytest、Allure、Selenium和Jenkins实现自动化测试集成实例
python·selenium·jenkins·pytest·allure