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

相关推荐
淼_@淼1 天前
pytest简介
运维·服务器·pytest
奶茶精Gaaa2 天前
【ZJ】Pytest框架搭建
pytest
趙卋傑3 天前
接口自动化测试
python·pycharm·pytest
测试界萧萧4 天前
Jenkins+Allure+Pytest的持续集成
自动化测试·软件测试·功能测试·程序人生·ci/cd·jenkins·pytest
nvd115 天前
Pytest 中使用 SQLAlchemy 进行异步数据库测试
数据库·oracle·pytest
文人sec6 天前
pytest1-接口自动化测试场景
软件测试·python·单元测试·pytest
我的xiaodoujiao6 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 25--数据驱动--参数化处理 Excel 文件 2
前端·python·学习·测试工具·ui·pytest
我的xiaodoujiao14 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 24--数据驱动--参数化处理 Excel 文件 1
python·学习·测试工具·pytest
西游音月17 天前
(2)pytest+Selenium自动化测试-环境准备
selenium·测试工具·pytest