# -*- coding: utf-8 -*-
# @Time : 2023/7/10 15:39
# @Author : yanfa
# @user : yanfa
# @File : test_allure_06_for_add_severities.py
# @remark: allure2 添加用例优先级
""""""
import allure
"""一、allure2报告中添加用例优先级
应用场景:用例执行时,希望按照严重级别执行测试用例
解决:可以为每个用例添加一个等级的装饰器,对应报告字段Severity
用法:@allure.severity(allure.severity_level.TRIVIAL)
共提供5个级别:
Blocker级别:中断缺陷(客户端程序无响应,无法执行下一步操作)。
Critical级别:临界缺陷( 功能点缺失)。
Normal级别:普通缺陷(数值计算错误)。
Minor级别:次要缺陷(界面错误与UI需求不符)。
Trivial级别:轻微缺陷(必输项无提示,或者提示不规范)。
使用装饰器添加类/方法级别,注意类上添加的级别对类中没添加级别的方法生效
运行方式:添加命令行参数--allure-severities [normal,blocker,..] 会执行不添加severities和逗号分隔的优先级对应的用例
例子: pytest xxx.py --alluredir=./results --clean-alluredir --allure-severities normal,blocker
"""
def test_with_no_severity():
pass
@allure.severity(allure.severity_level.BLOCKER)
def test_with_severity_for_blocker():
pass
@allure.severity(allure.severity_level.CRITICAL)
def test_with_severity_for_critical():
pass
@allure.severity(allure.severity_level.NORMAL)
def test_with_severity_for_normal():
pass
@allure.severity(allure.severity_level.MINOR)
def test_with_severity_for_minor():
pass
@allure.severity(allure.severity_level.TRIVIAL)
def test_with_severity_for_trivial():
pass
@allure.severity(allure.severity_level.NORMAL)
class TestWithNormal():
def test_with_no(self):
"""注意类上添加的级别对类中没添加级别的方法生效"""
pass
@allure.severity(allure.severity_level.TRIVIAL)
def test_with_yes(self):
pass