300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > Allure定制化标签(用例等级\项目描述\模块名称\缺陷连接\定义链接\添加附件等)

Allure定制化标签(用例等级\项目描述\模块名称\缺陷连接\定义链接\添加附件等)

时间:2024-01-04 07:19:58

相关推荐

Allure定制化标签(用例等级\项目描述\模块名称\缺陷连接\定义链接\添加附件等)

allure官方文档

http://allure.qatools.ru/

一、allure定制化标签

示例1:演示了基本allure定制化标签的使用方法

1、test_allure_example_001.py # 见图-001、002@allure.epic('淘宝')# 工程级别@allure.feature('设置') # 模块级别,一级标签@allure.story('账户安全') # 模块级别,二级标签@allure.title('用例标题:test_001') # 三级标签

test_allure_example_001.py内容:import pytestimport osimport allure@allure.epic('淘宝') # 工程级别@allure.feature('设置') # 模块级别,一级标签class Test10:@pytest.mark.parametrize('result,real_result', [[3**3, 27], [2**25, 33554432], [5, 5]]) # 参数化@allure.story('账户安全') # 模块级别,二级标签@allure.title('用例标题:test_001') # 三级标签def test_001(self, result, real_result):assert result == real_result@allure.story('通知提醒') # 模块级别,二级标签@allure.title('用例标题:test_002') # 三级标签def test_002(self):assert 1 == 1@allure.story('隐私设置') # 模块级别,二级标签@allure.title('用例标题:test_003') # 三级标签def test_003(self):assert 1 == 1@allure.story('主题显示') # 模块级别,二级标签@allure.title('用例标题:test_004') # 三级标签def test_004(self):assert 1 == 1if __name__ == '__main__':pytest.main(['test_allure_example_001.py', '-s', '--alluredir', '../report/tmp'])os.system('allure generate ../report/tmp -o ../report/report --clean')# os.system('allure serve ../report/tmp -o ../report/report --clean')

图-001

图-002

示例2:演示了所有allure定制化标签的使用方法

test_allure_example_002.py # 见图-003演示了所有allure定制化标签的使用方法。@allure.epic() # 项目描述,敏捷里面的概念,定义史诗,往下是feature@allure.feature() # 模块名称,功能点的描述,往下是story@allure.tag() # 用例标记,自定义内容@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.attach()# 添加附件,通常是一些测试数据信息@allure.attach.file() # 添加附件,通常是一些测试数据信息

test_allure_example_002.py内容:import pytestimport osimport 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("测试项目:APP")@allure.feature("1级标签_测试模块:1")@allure.tag("核心关注")@allure.testcase("")@allure.issue("/")@allure.link("/")class TestC1():@allure.title("测试用例的标题:test_1")@allure.story("2级标签_测试模块:1")@allure.severity("blocker")# 用例等级@allure.description("我是用例test_1的描述内容-description") # 用例描述,优先级大于在用例下的注解:''我是用例test_1.1的描述内容-description'''def test_1(self, login):'''我是用例test_1.1的描述内容-description'''print("测试用例1")step_1()step_2()@allure.description("我是用例test_2的描述内容-description") # 用例描述@allure.story("2级标签_测试模块:2")def test_2(self, login):print("测试用例2")step_1()step_3()@allure.epic("测试项目:APP")@allure.feature("1级标签_测试模块:2")@allure.tag("重点关注")@allure.testcase("")@allure.issue("/")@allure.severity("critical")# 用例等级class TestC2():@allure.story("2级标签_测试模块:3")@allure.description("我是用例test_3的描述内容-description") # 用例描述def test_3(self, login):print("测试用例3")step_1()@allure.tag("一般关注")@allure.story("2级标签_测试模块:4")@allure.description("我是用例test_4的描述内容-description") # 用例描述def test_4(self, login):print("测试用例4")step_3()if __name__ == '__main__':pytest.main(['test_allure_example_002.py', '-s', '--alluredir', '../report/tmp'])os.system('allure generate ../report/tmp -o ../report/report --clean')# os.system('allure serve ../report/tmp -o ../report/report --clean')

图-003

示例3:在报告里添加附件

test_allure_example_003.py # 见图-004allure.attach.file()# 添加附件,在报告里添加附件

test_allure_example_003.py内容:import pytestimport osimport allure@allure.epic("测试项目:APP")@allure.feature("1级标签_测试模块:1")class TestAllure():@allure.story("2级标签_测试模块:1")@allure.title("用例标题-1")@allure.story("2级标签_测试模块:2")@allure.title("用例标题-2")def test_1(self):allure.attach.file(r'.\test_001.png', '我是附件截图的名字', attachment_type=allure.attachment_type.JPG)if __name__ == '__main__':pytest.main(['test_allure_example_003.py', '-s', '--alluredir', '../report/tmp']) os.system('allure generate ../report/tmp -o ../report/report --clean')# os.system('allure serve ../report/tmp -o ../report/report --clean')

图-004

示例4:设置用例级别 @allure.severity()

用例等级,按严重级别来标记,blocker,critical,normal,minor,trivialpytest -case --alluredir=../report/tmp --allure-severities=normal,critical BLOCKER = 'blocker' 阻塞缺陷CRITICAL = 'critical' 严重缺陷NORMAL = 'normal' 一般缺陷MINOR = 'minor' 次要缺陷TRIVIAL = 'trivial' 轻微缺陷

# 代码示例:import pytestimport allure@allure.severity("normal")def test_case_1():print("test case 1")@allure.severity("critical")def test_case_2():print("test case 2")@allure.severity("critical")def test_case_3():print("test case 3")@allure.severity("blocker")def test_case_4():print("test case 4")def test_case_5():print("test case 5")

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。