--clean-alluredir && 用例优先级@allure.severity

1.清空历史数据   --clean-alluredir

 pytest.main(['-s','-q','--alluredir','./report/allure_raw','--clean-alluredir'])
    #第一种方式  直接启动服务打开
    os.popen('allure serve report/allure_raw')

2.allure.severity

allure对用例的等级划分成五个等级

  • blocker  阻塞缺陷(功能未实现,无法下一步)
  • critical  严重缺陷(功能点缺失)
  • normal   一般缺陷(边界情况,格式错误)
  • minor  次要缺陷(界面错误与ui需求不符)
  • trivial   轻微缺陷(必须项无提示,或者提示不规范)

示例

import pytest
import allure
'''
作者:上海-悠悠 qq交流群:874033608

@allure.severity装饰器按严重性级别来标记case   
执行指定测试用例 --allure-severities blocker
BLOCKER = 'blocker'  阻塞缺陷
CRITICAL = 'critical' 严重缺陷
NORMAL = 'normal'    一般缺陷
MINOR = 'minor'      次要缺陷
TRIVIAL = 'trivial'  轻微缺陷 
'''


@allure.severity("normal")
def test_case_1():
    '''修改个人信息-sex参数为空'''
    print("test case 11111111")
    

@allure.severity("critical")
def test_case_2():
    '''修改个人信息-sex参数传F和M两种类型,成功(枚举类型)'''
    print("test case 222222222")


@allure.severity("critical")
def test_case_3():
    '''修改个人信息-修改不是本人的用户信息,无权限操作'''
    print("test case 333333333")

@allure.severity("blocker")
def test_case_4():
    '''修改个人信息-修改自己的个人信息,修改成功'''
    print("test case 4444444")


def test_case_5():
    '''没标记severity的用例默认为normal'''
    print("test case 5555555555")

统计图

按等级执行

pytest --alluredir=./report/allure --allure-severities=blocker,critical
原文地址:https://www.cnblogs.com/bigbox/p/13138592.html