allure-12-添加附件

2019-07-14  本文已影响0人  果芽软件

一、附件类型

类型 类型值
文本 allure.attachment_type.TEXT
CSV allure.attachment_type.CSV
图片 allure.attachment_type.JPG或PNG
PDF allure.attachment_type.PDF
html文件 allure.attachment_type.HTML
json文件 allure.attachment_type.JSON
xml文件 allure.attachment_type.XML
mp4 allure.attachment_type.MP4

二、添加字符串附件

allure.attach(body,name,attachment_type,extention)
参数名 含义 举例
body 要添加的内容 如response.json()
name 附件的文件名 如响应报文
attachment_type 如text,见附件类型 见类型表
extention 附件保存的文件后缀(可不填)

二、示例

class TestSignUp:
        def login(self):
        url = ''
        req = {
            "pwd": "string",
            "userName": "string"
        }
        allure.attach(req, '请求', allure.attachment_type.TEXT)
        resp = requests.post(url, json=req)
        allure.attach(resp.text, '响应', allure.attachment_type.TEXT)

三、查看报告

image.png
上一篇下一篇

猜你喜欢

热点阅读