Allure2 报告中添加附件 - HTML
简介
Allure 可以定制测试报告页面效果,可以将 HTML 类型的附件显示在报告页面上。
Allure2 报告中添加 HTML 附件
Python 版本
- 语法:
allure.attach(body, name, attachment_type, extension)
,参数解释:- body:要写入附件的内容(HTML 代码块)。
- name:附件名字。
- attachment_type:附件类型,是
allure.attachment_type
其中的一种。 - extension:附件的扩展名。
class TestWithAttach:
def test_html(self):
allure.attach('<head></head><body> a page </body>',
'附件是HTML类型',
allure.attachment_type.HTML)
def test_html_part(self):
allure.attach('''html代码块''',
'附件是HTML类型',
allure.attachment_type.HTML)
Java 版本
方式一:注解方式
使用 @Attachment
直接传入 HTML 文件。
@Attachment(value = "html名", type = "text/html", fileExtension = "后缀")
方式二:调用方法添加
使用 Allure.addAttachment
方法传入 HTML。
Allure.addAttachment("html名", "text/html",
图片路径, "后缀");
总结
- Allure 报告中添加 HTML 附件- Python
- Allure2 报告中添加 HTML 附件 - Java