allure测试报告框架

基本特性:

  1. @allure.feature(“test feature describition”) ## 用于定义被测试的功能,被测产品的需求点

  2. @allure.story(“test story describition”) ## 用于定义被测功能的用户场景,即子功能点

  3. with allure.step(test step describition"): ## 用于将一个测试用例,分成几个步骤在报告中输出

  4. @allure.step(“test step describition”) # 用于将一些通用的函数作为测试步骤输出到报告,调用此函数的地方会向报告中输出步骤

  5. @allure.severity(“critical”). Allure中对严重界别的定义,以下为取值范围:
    1)blocker:中断缺陷(客户端程序无响应,无法执行下一步操作)
    2)critical:临界缺陷( 功能点缺失)
    3)normal:普通缺陷(数值计算错误)
    4)minor:次要缺陷(界面错误与UI需求不符)
    5)trivial:轻微缺陷(必输项无提示,或者提示不规范)

  6. allure.attach(name,contents,type) # 在报告中增加附件
    1)name:在报告中显示的附件名称
    2)content:表示添加附件的内容
    3)type: 添加的附件类型(支持:TEXT、HTML、XML、PNG、JPG、JSON、OTHER) allure.attach_type.TEXT

  7. allure.issue(*issue) #测试报告中对应的bug

  8. allure.testcase(*testcase) #测试报告中对应的testcase

@allure.feature(''测试featureA功能")
class TestFeature():
		@allure.story("测试场景一")
		@allure.severity("blocker")
		@allure.issue("http://www.pms-XXX.bug-XXX)
		@allure.testcase("http://www.testlink.com")
		def test_story1(self):
		"""用例描述"""
				with allure.step("测试步骤一"):
						with open("/path/screencap.png", "rb") as f:
								allure.attach("当前截图",f.read(),allure.attach_type.PNG)
				with allure.step(“测试步骤二”):
						pass
				self.common_step1()
				self.common_step2()				
			
		@allure.step2("通用测试步骤三"):
		def common_step():
				pass
				
		@allure.step("通用测试步骤四,参数1:{0},参数2:{1}"):#测试步骤,可以通过format机制自动获取函数参数
		def common_step2(arg1,arg2):
				pass

测试用例fail时自动保存当前截图并attach到测试报告

测试用例中assert判断语句用try……except捕获,然后进行截图保存并attach处理

def test1():
	try:
		assert 1==2
	except AssertionError as e:
		cmd.Fail(failReason) #通用函数处理fail

def Fail(failReason):
	f=savescreencap(imagePath)#保存截图到本地
	with open(imagePath, 'rb') as f:
         allure.attach("图片匹配失败,目标图片",f.read(), allure.attach_type.PNG)	#attach 截图到测试报告
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值