ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

pytest--allure描述用例详细讲解

2021-09-14 10:31:31  阅读:219  来源: 互联网

标签:story -- pytest 用例 step allure


前言

pytest+allure是最完美的结合了,关于allure的使用,本篇做了一个总结。

allure报告可以包含很多详细的信息描述测试用例,包括epic、feature、story、title、issue、testcase、severity等

allure用例描述

img

测试案例

pytest结合allure测试用例

#test_a.py
import pytest
import allure
@pytest.fixture(scope="session")
def login():
    print("前置条件:登录")
 
@allure.step("步骤1")
def step_1():
    print("操作步骤----1")
 
@allure.step("步骤2")
def step_2():
    print("操作步骤----2")
 
@allure.step("步骤3")
def step_3():
    print("操作步骤----3")
 
@allure.epic("epic对大story的一个描述性标签")
@allure.feature("测试模块")
class TestC:
    @allure.testcase("http://www.tc.com")
    @allure.issue("https://www.bug.com/")
    @allure.title("测试用例的标题")
    @allure.story("用户故事:1")
    @allure.severity("blocker")
    def test_1(self,login):
        '''我是用例1的描述内容,看的见我不'''
        step_1()
        step_2()
 
    @allure.story("用户故事:2")
    def test_2(self,login):
        print("测试用例2")
        step_1()
        step_3()
@allure.epic("epic对大story的一个描述性标签")
@allure.feature("模块块2")
class TestC2():
    @allure.story("用户故事:33")
    def test_3(self,login):
        print("测试用例test_3")
        step_1()
 
    @allure.story("用户故事:44")
    def test_4(self,login):
        print("测试用例test_4")
        step_3()  

执行用例

cd到test_a.py的目录

pytest --alluredir ./report/a  

生成报告

allure serve ./report/a  

报告展示内容

img

命令行参数

pytest运行用例的时候可以加上allure标记用例的参数

--allure-severities=SEVERITIES_SET
                        Comma-separated list of severity names. Tests only
                        with these severities will be run. Possible values
                        are: blocker, critical, normal, minor, trivial.
--allure-epics=EPICS_SET
                        Comma-separated list of epic names. Run tests that
                        have at least one of the specified feature labels.
--allure-features=FEATURES_SET
                        Comma-separated list of feature names. Run tests that
                        have at least one of the specified feature labels.
--allure-stories=STORIES_SET
                        Comma-separated list of story names. Run tests that
                        have at least one of the specified story labels.
--allure-link-pattern=LINK_TYPE:LINK_PATTERN
                        Url pattern for link type. Allows short links in test,
                        like 'issue-1'. Text will be formatted to full url
                        with python str.format().  

选择运行你要执行epic的用例

pytest --alluredir ./report/allure --allure-epics=epic对大Story的一个描述性标签

选择运行你要执行features的用例

pytest --alluredir ./report/allure --allure-features=模块2

选择运行你要执行features的用例

pytest --alluredir ./report/allure --allure-stories="用户故事:1"

关于allure的使用基本上就是这些了

标签:story,--,pytest,用例,step,allure
来源: https://www.cnblogs.com/ye-peng/p/15266411.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有