pytest+allure的应用

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

方法作用说明
@allure.epic()epi描述
@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()附件报告添加附件

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

原博客:allure(三十)--allure描述用例详细讲解 - 星空6 - 博客园 


版权声明:本文为lijunyan5原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。