软件测试学习笔记丨Allure2 报告中添加附件(视频)

171 阅读1分钟

本文转自测试人社区,原文链接:ceshiren.com/t/topic/301…

Allure2 报告中添加附件(视频)

  • 应用场景:在做 UI 自动化测试时,可以将页面截图,或者出错的页面进行截图,将截图添加到测试报告中展示,辅助定位问题。

  • 解决方案:
    Python:使用 allure.attach.file() 添加视频。
import allure

class TestWithAttach:
    def test_video(self):
        allure.attach.file("xxx.mp4",
                           name="视频",
                           attachment_type=allure.attachment_type.MP4,
                           extension="mp4")

语法:allure.attach.file(source, name, attachment_type, extension),参数解释:

  • source:文件路径,相当于传一个文件。
  • name:附件名字。
  • attachment_type:附件类型,是 allure.attachment_type 其中的一种。
  • extension:附件的扩展名。