pytest框架--allure报告用例参数详解

原文链接,感谢作者:http://www.manongjc.com/detail/18-uxknglitylthfjx.html

1、测试案例:

#test_allure_demo.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()  

2、执行并打开报告:
执行用例: pytest -vs test_allure_demo.py --alluredir ./report/a ,
在这里插入图片描述
打开报告:allure serve ./report/a
在这里插入图片描述
3、allure 报告页面
在这里插入图片描述
4、按需执行用例:
a.选择运行你要执行epic的用例:
pytest --alluredir ./report/allure --allure-epics=epic对大Story的一个描述性标签
b.选择运行你要执行features的用例:
pytest --alluredir ./report/allure --allure-features=模块块2
c.选择运行你要执行features的用例:
pytest --alluredir ./report/allure --allure-stories=“用户故事:1”

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值