26-pytest-allure描述用例详解

简介: 26-pytest-allure描述用例详解

前言

  • 本篇来总结下,allure用例描述的方法

allure用例描述

使用方法 参数值 参数说明
@allure.epic() epic描述 敏捷里面的概念,定义史诗,往下是feature
@allure.feature() 模块名称 功能点的描述,往下是story
@allure.story() 用户故事 用户故事,往下是title
@allure.title() 用例的标题 重命名html报告名称
@allure.testcase() 测试用例的链接地址 对应功能测试用例系统里面的case
@allure.issue() 缺陷 对应缺陷管理系统里面的链接
@allure.description() 用例描述 测试用例的描述
@allure.step() 操作步骤 测试用例的步骤
@allure.severity() 用例等级 blocker,critical,normal,minor,trivial
@allure.link() 链接 定义一个链接,在测试报告展现
@allure.attachment() 附件 报告添加附件

使用示例

# -*- coding: utf-8 -*-
# @Time    : 2022/3/19
# @Author  : 大海
import os
import pytest
import allure
@pytest.fixture(scope="session")
def login_fixture():
    print("前置条件:登录")
@allure.step("打开商品详情页")
def step_1():
    print("操作步骤1:打开商品详情页")
@allure.step("添加购物车")
def step_2():
    print("操作步骤2:添加购物车")
@allure.step("去结算支付")
def step_3():
    print("操作步骤3:去结算支付")
@allure.epic("epic对大Story的一个描述性标签")
@allure.feature("测试模块")
class TestDemoAllure:
    @allure.testcase("https://blog.csdn.net/IT_heima")
    @allure.issue("https://blog.csdn.net/IT_heima")
    @allure.title("用例标题")
    @allure.story("用户故事:1")
    @allure.severity("critical")
    def test_case_1(self, login_fixture):
        """
        case description:
        1.打开商品详情页
        2.商品加入购物车
        3.结算支付
        """
        step_1()
        step_2()
        step_3()
if __name__ == '__main__':
    os.system('pytest -s test_48.py --alluredir=./allure_report --clean-alluredir')
    os.system('allure serve ./allure_report')
  • 查看报告
  • 执行指定用例
# 执行指定的epic  --clean-alluredir是清空上次报告
pytest --alluredir ./report/allure --allure-epics=epic对大Story的一个描述性标签 --clean-alluredir
# 执行指定的features
pytest --alluredir ./report/allure --allure-features=测试模块
# 执行指定的stories
pytest --alluredir ./report/allure --allure-stories="用户故事:1"


相关文章
|
4月前
|
测试技术
自动化测试项目学习笔记(五):Pytest结合allure生成测试报告以及重构项目
本文介绍了如何使用Pytest和Allure生成自动化测试报告。通过安装allure-pytest和配置环境,可以生成包含用例描述、步骤、等级等详细信息的美观报告。文章还提供了代码示例和运行指南,以及重构项目时的注意事项。
406 1
自动化测试项目学习笔记(五):Pytest结合allure生成测试报告以及重构项目
|
9月前
|
测试技术 Python
cypress 和allure 集成生成测试报告
cypress 和allure 集成生成测试报告
186 1
cypress 和allure 集成生成测试报告
|
9月前
|
运维 测试技术
实用指南:使用Pytest Allure测试框架添加用例失败截图
本文介绍了如何在使用`allure+pytest`进行软件测试时,通过`pytest_runtest_makereport`钩子函数自动捕获失败用例的截图。在`conftest.py`中定义钩子,当用例失败时,保存截图并附加到Allure测试报告中。测试代码示例展示了登录豆瓣的场景,测试失败时会自动生成截图。这种方法有助于快速理解和解决测试问题,提升测试效率和软件质量。
|
XML Java 测试技术
Pytest-测试报告Allure
Pytest-测试报告Allure
379 0
|
测试技术
22-pytest-allure.step()测试步骤描述
22-pytest-allure.step()测试步骤描述
|
JSON 测试技术 数据格式
19-pytest-allure-pytest环境搭建
19-pytest-allure-pytest环境搭建
|
自然语言处理 Java 测试技术
pytest学习和使用21-测试报告插件allure-pytest如何使用?
pytest学习和使用21-测试报告插件allure-pytest如何使用?
180 0
pytest学习和使用21-测试报告插件allure-pytest如何使用?
|
负载均衡 监控 测试技术
pytest学习和使用20-pytest如何进行分布式测试?(pytest-xdist)
pytest学习和使用20-pytest如何进行分布式测试?(pytest-xdist)
225 0
pytest学习和使用20-pytest如何进行分布式测试?(pytest-xdist)
|
测试技术 Python
pytest学习和使用17-Pytest如何重复执行用例?(pytest-repeat)
pytest学习和使用17-Pytest如何重复执行用例?(pytest-repeat)
163 0
pytest学习和使用17-Pytest如何重复执行用例?(pytest-repeat)
|
测试技术 Python
pytest学习和使用2-初步使用和用例运行
pytest学习和使用2-初步使用和用例运行
106 0
pytest学习和使用2-初步使用和用例运行