zoukankan      html  css  js  c++  java
  • Pytest学习(二十三)- allure 之 @allure.epic()、@allure.feature()、@allure.story() 的使用

    前言

    这三个注解,个人觉得和BDD即行为驱动类似,学习思路参考cucumber,而allure提供的这三个标记装饰器,它们是可以显示在allure报告上的。

    allure的标记装饰器

    • BDD样式的标记装饰器
    • 优先级(严重程度)标记装饰器
    • 自定义标记装饰器

    BDD标记装饰器

    提供了三个装饰器

    • @allure.epic:敏捷里面的概念,定义史诗,往下是 feature
    • @allure.feature:功能点的描述,理解成模块往下是 story
    • @allure.story:故事,往下是 title

    示例代码如下:

    # -*- coding: utf-8 -*-
    # @Time    : 2020/12/13 8:32
    # @Author  : longrong.lang
    # @FileName: test_mark.py
    # @Software: PyCharm
    # @Cnblogs :https://www.cnblogs.com/longronglang
    
    import allure
    import pytest
    
    
    @pytest.fixture(scope="session")
    def login_fixture():
        print("=== 前置登录 ===")
    
    
    @allure.step("步骤1")
    def step_1():
        print("操作步骤 查找商品---------------1")
    
    
    @allure.step("步骤2")
    def step_2():
        print("操作步骤 将商品加入购物车---------------2")
    
    
    @allure.epic("epic 此处为总体描述")
    @allure.feature("测试模块,如加入购物车")
    class TestAllure:
    
        @allure.testcase("https://www.cnblogs.com/longronglang/", '测试用例使用链接')
        @allure.issue("https://www.cnblogs.com/longronglang/", 'Bug使用链接')
        @allure.title("用例的标题(将商品加入购物车)")
        @allure.story("story one")
        # 严重级别
        @allure.severity("critical")
        @allure.story("检索商品并加入购物车")
        @allure.title("久曲健博客:https://www.cnblogs.com/longronglang/")
        def test_case_1(self, login_fixture):
            print("测试用例1")
            step_1()
            step_2()
    
    

    测试报告展示如下

  • 相关阅读:
    CentOS7搭建SFTP服务
    MySQL主从异常恢复
    MySQL主从复制配置
    Docker安装MySQL8.0
    CentOS7安装JDK1.8
    RabbitMQ死信队列
    RabbitMQ重试机制
    RabbitMQ消息可靠性传输
    TCP/IP的Socket编程
    c#网络编程使用tcpListener和tcpClient
  • 原文地址:https://www.cnblogs.com/longronglang/p/14128414.html
Copyright © 2011-2022 走看看