• allure(三十)--allure描述用例详细讲解


    前言

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

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

    allure用例描述

     测试案例

    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  

    报告展示内容

     命令行参数

    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的使用基本上就是这些了

    越努力,越幸运!!! good good study,day day up!!!
  • 相关阅读:
    iOS单选和全选
    仿微信-ActionSheet
    NSArray 快速求和、平均值、最大值、最小值
    iOS学习资源集合
    iOS-Runtime字体适配
    仿网易新闻标题栏
    极光推送封装
    iOS导航栏自由缩放头像效果
    iOS判断字母、数字串
    Perl6多线程3: Promise start / in / await
  • 原文地址:https://www.cnblogs.com/canglongdao/p/13414829.html
Copyright © 2020-2023  润新知