【pytest-23】allure特性之severity和issue
前言
前面介绍allure了4种特性,接下来继续
- @allure.severity 标记用例等级,分为以下5个等级
- blocker 阻塞缺陷(功能未实现,无法下一步)
- critical 严重缺陷(功能点缺失)
- normal 一般缺陷(边界情况,格式错误)
- minor 次要缺陷(界面错误与ui需求不符)
- trivial 轻微缺陷(必须项无提示,或者提示不规范)
- @allure.issue 对应缺陷管理系统的bug链接
比如我这里的缺陷管理系统

220:minor
219:blocker
208:normal
132:critical
131:normal
使用
#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.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): # ''' # 测试添加和保存 # :return: # ''' with allure.step('步骤2:搜索'): search() with allure.step('步骤3:编辑增加'): edit() with allure.step('步骤4:保存'): save() @allure.severity("critical") @allure.story("我是story2") @allure.title("保存成功用例") def test_save_success(login_setup): 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()
根据测试用例的重要性划分测试用例等级,如果没指定等级,默认为normal级别
运行结果:

统计缺陷
这里全是通过的

allure命令行参数allure-severities
如果你只想根据用例的级别去运行,我只想运行blocker和critical级别的用例
pytest --alluredir ./report/allure --allure-severities blocker,critical
or
pytest --alluredir=./report/allure --allure-severities=blocker,critical
善于跌倒仍喜爱奔跑~

浙公网安备 33010602011771号