【pytest-24】allure特性之description,testcase,link

前言

前面基本介绍了allure的特性,这篇文章继续

  • @allure.description() :添加测试用例描述
  • @allure.testcase():测试用例链接,对应功能测试用例系统里面的case
  • @allure.link():定义一个链接,在测试报告展现

使用

#encoding:utf-8
#@Time:2020/12/21 11:32
#@Author:sunny

import allure
from common.com_utils import *
import pytest

'''
1.登录,2.查询数据 3.编辑 4.保存
'''

def login(username,password):
    '''前置操作1:登录'''
    print("前置操作:先登录")

def search():
    print("搜索")

def edit(id="23"):
    print("编辑增加")

def save():
    print("保存")

@pytest.fixture(scope="session")
def login_setup():
    login("xiaoxiao","123")


@allure.epic("我是epic")
@allure.feature("我feature,是排期模块")
class TestA():

    @allure.link("https://www.baidu.com/")
    @allure.testcase("http://zentao.aamcn.com.cn/zentao/testcase-view-xxx.html")
    @allure.issue("http://zentao.aamcn.com.cn/zentao/bug-view-xxx.html")
    @allure.severity("blocker")
    @allure.story("我是story1")
    @allure.title("我是添加保存用例")
    def test_add_save(login_setup):
       '''
       description:
       测试添加和保存
       :return:
       '''
       with allure.step('步骤2:搜索'):
           search()
       with allure.step('步骤3:编辑增加'):
           edit()
       with allure.step('步骤4:保存'):
           save()

    @allure.link("https://www.google.com/")
    @allure.testcase("http://zentao.aamcn.com.cn/zentao/testcase-view-xxx.html")
    @allure.severity("critical")
    @allure.story("我是story2")
    @allure.title("保存成功用例")
    def test_save_success(login_setup):
        """
        description:我是测试保存成功
        :return:
        """
        pass

    @allure.issue("http://zentao.aamcn.com.cn/zentao/bug-view-xxx.html")
    @allure.severity("normal")
    def test_search_success(login_setup):
        pass


@allure.epic("我是函数的epic")
@allure.title("我是函数的title")
@allure.feature("我是函数的feature2")
@allure.story("我是函数的story3")
def test_aa():
    with allure.step('步骤2:搜索'):
        search()
    with allure.step('步骤3:编辑增加'):
        edit()
    with allure.step('步骤4:保存'):
        save()

运行结果:

 注意:仔细的可以看出,@allure.issue、@allure.issue、@allure.link的效果一样,我们可以选择一个使用,可以后面传name以标识。当然如果场景需要测试用例,bug链接,和测试地址链接都传,也可以。

  @allure.link("https://www.baidu.com/","我是百度链接") 

 

posted @ 2020-12-29 09:43  做一只热爱生活的小透明  阅读(203)  评论(0)    收藏  举报