做批发网站有哪些,免费单页网站在线制作,海兴做网站,网站中下滑菜单怎么做目录 1. 搭建allure环境
2. 生成报告
3. logo定制
4. 企业级报告内容或层级定制
5. allure局域网查看 1. 搭建allure环境
1.1 JDK#xff0c;使用PyCharm
找到pycharm安装目录找到java.exe记下jbr目录的完整路径#xff0c;eg: C:\Program Files\JetBrains\PyCharm Com…目录 1. 搭建allure环境
2. 生成报告
3. logo定制
4. 企业级报告内容或层级定制
5. allure局域网查看 1. 搭建allure环境
1.1 JDK使用PyCharm
找到pycharm安装目录找到java.exe记下jbr目录的完整路径eg: C:\Program Files\JetBrains\PyCharm Community Edition 2022.3\jbr\bin将地址添加进入环境变量重启 1.2 allure程序
下载地址https://github.com/allure-framework/allure2/releases解压到指定路径。eg: D:\study\allure-2.25.0\allure-2.25.0\bin执行allurePath 追加allure安装路径验证是否安装成功在dos窗口和Pycharm需要重启加载环境变量中都需要验证allure --version 2. 生成报告
2.1 生成临时的json格式的报告
addopts -vs --alluredir./temps --clean-alluredir
; --clean-alluredir生成临时报告并清除
2.2 生成HTML的allure报告
if __name__ __main__:pytest.main([./test_study/test_fixture.py])os.system(allure generate ./temps -o ./reports --clean) # -o 指定输出测试报告路径# --clean 清空历史数据# ./temps 表示用来生成html的JSON临时文件目录# ./reports 表示html文件生成目录
3. logo定制
3.1 在D:\study\allure-2.25.0\allure-2.25.0\config目录下的allure.yml中配置自定义的logo插件【- custom-logo-plugin】 3.2 重新运行并生成allue报告
3.3 增加一个自己的logo文件并修改D:\study\allure-2.25.0\allure-2.25.0\plugins\custom-logo-plugin\static路径下的styles.css文件里面的样式最好将需要修改的logo也放在custom-logo-plugin目录下
.side-nav__brand {background: url(1.png) no-repeat left center !important; //将你需要的logo图片地址放在这里margin-left: 22px; //调整方位height: 90px; //调整大小background-size: contain !important;
}
//去掉图片后边 allure 文本
.side-nav__brand-text{display: none;
}
//配置logo 后面的字体样式与字体大小
.side-nav__brand:after {content: 测试测试;margin-left: 18px;height: 20px;font-family: Arial;font-size: 13px;
} 注logo图片和文字可以同时存在也可以只要一个 4. 企业级报告内容或层级定制
左边
1. 项目名称史诗allure.epic(测试报告)
2. 模块名称特性allure.feature(测试模块)
3. 接口名称分组allure.story(测试接口)
allure.epic(测试报告)
allure.feature(测试模块)
class TestA:allure.story(测试1)def test_1(self):print(11111)allure.story(测试2)def test_2(slef):print(22222) 将多个用例写到一个组
allure.story(测试1)
allure.title(用例1)
def test_1(self):print(11111)allure.story(测试1)
def test_2(slef):allure.dynamic.title(用例2)print(22222)
4. 用例标题allure.title(用例1) or allure.dynamic.title(用例2) 两种方法都可以实现
allure.title(用例1) //方法1
def test_1(self):print(11111)allure.story(测试2)
def test_2(slef):allure.dynamic.title(用例2) //方法2print(22222) 右边
1. 测试用例严重级别allure.severity(allure.severity_level.BLOCKER) //BLOCKER(致命)CRITICAL严重,NORMAL(一般)MINOR提示TRIVIAL轻微一般默认为NORMAL
allure.severity(allure.severity_level.TRIVIAL)
allure.story(测试3)
def test_3(slef):print(33333) 2. 测试用例的描述allure.description(测试用例的描述)
allure.description(测试用例的描述方法1)
allure.title(测试4)
def test_4(slef):print(44444)allure.title(测试5)
def test_5(slef):allure.dynamic.description(测试用例的描述方法2)print(55555)
3. 接口访问链接allure.link(接口链接)
4. BUG链接allure.issue(bug链接)
5. 测试用例链接allure.testcase(用例链接)
allure.story(测试6)
allure.link(https://www.baidu.com/0,name接口链接)
allure.issue(https://www.baidu.com/,namebug链接)
allure.testcase(https://www.baidu.com/,name用例链接)
def test_6(slef):print(66666) 6. 测试用例的操作步骤allure.step(第str(i)步):
allure.story(测试1)
def test_7(self):for i in range(0,10):with allure.step(第str(i)步):pass 7. 测试附件allure.attach(bodycontent,name错误截图,attachment_typeallure.attachment_type.PNG) //一般用于错误截图常用于web自动化测试
allure.story(测试1)
def test_8(self):# 附件上传需要使用二进制可以是图片可以是文本可以是其它文件with open(rD:\study\allure-2.25.0\allure-2.25.0\plugins\custom-logo-plugin\static\1.png,moderb) as f:content f.read()allure.attach(bodycontent,name错误截图,attachment_typeallure.attachment_type.PNG) 8. 文本内容的定制一般应用于接口自动化
allure.story(测试1)
def test_9(self):# 请求allure.attach(https://www.baidu.com/0,name接口地址,attachment_typeallure.attachment_type.TEXT)allure.attach(接口参数一般从yaml中获取,name接口参数,attachment_typeallure.attachment_type.TEXT)allure.attach(请求方式get/post,name请求方式,attachment_typeallure.attachment_type.TEXT)allure.attach(请求头一般从yaml中获取,name请求头,attachment_typeallure.attachment_type.TEXT)# 响应allure.attach(响应文本一般从yaml中获取, name响应文本, attachment_typeallure.attachment_type.TEXT)allure.attach(执行结果成功/失败, name执行结果, attachment_typeallure.attachment_type.TEXT) 9. 数据驱动
allure.story(测试1)
pytest.mark.parametrize(x, [这是第1个测试值, 这是第2个测试值])
def test_a(self,x):print(ftest_a中的X值为{x}) 由于使用数据驱动用例标题会展示参数数据化驱动中的所有参数若不想要显示则需要修改allure配置
# 修改前
test_result.parameters.extend([Parameter(namename, valuerepresent(value)) for name, value in params.items()if name not in current_param_names])# 修改后 将列表内容去除即可
test_result.parameters.extend([]) 5. allure局域网查看
局域网内网allure open ./reports
if __name__ __main__:pytest.main([./test_study/test_allure.py])os.system(allure generate ./temps -o ./reports --clean)os.system(allure open ./reports)