Allure2 报告中添加附件 - 视频
简介
在做 UI 自动化测试时,可以将页面截图,或者出错的页面进行截图,将截图添加到测试报告中展示。
Allure2 报告中添加视频附件
Python 版本
- 语法:
allure.attach.file(source, name, attachment_type, extension)
,参数解释:- source:文件路径,相当于传一个文件。
- name:附件名字。
- attachment_type:附件类型,是
allure.attachment_type
其中的一种。 - extension:附件的扩展名。
import allure
class TestWithAttach:
def test_video(self):
allure.attach.file("xxx.mp4",
name="视频",
attachment_type=allure.attachment_type.MP4,
extension="mp4")
Java 版本
方式一: 注解方式
使用@Attachment
注解直接传入视频。
@Attachment(value = "视频名", type = "video/mp4", fileExtension = "后缀")
方式二: 调用方法添加
使用 Allure.addAttachment
方法传入视频。
Allure.addAttachment("视频名", "video/mp4",
视频路径, "后缀");
总结
- Allure 报告中添加视频附件简介
- Allure 报告中添加视频附件 - Python
- Allure 报告中添加视频附件 - Java