(allure报告定制)

发布时间 2023-10-09 23:27:54作者: yimu-yimu

用例的严重程度级别

blocker :中断缺陷、致命bug、数据丢失、系统奔溃。

critical:临界缺陷、严重bug功能为实现、功能错误、重复提交

normal:一般缺陷bug、条件查询有误、无响应

minor:次要用例级别,提示bug、颜色样式、字体排列错别字

trivial:轻微级别,轻微bug,必填项无提示。

import allure


@allure.epic('项目名称00,epic')
@allure.feature('测试模块,feature')  # 一般用在类上方
class TestAllureReport:
    @allure.title('测试用例标题00,title')
    @allure.story('测试成功,story')
    @allure.severity(allure.severity_level.CRITICAL)
    @allure.description('用例的描述,description')
    @allure.issue("输入缺陷管理系统的链接", name='bug链接issue')
    @allure.link("设置一个链接", name='链接名称link')
    @allure.testcase(url='测试用例地址', name='测试用例name,testcase')
    def test_example(self):

        with allure.step("步骤1:执行某个操作"):
            # 这里执行某个操作,例如:
            result = 1 + 1

        with allure.step("步骤2:验证结果"):
            assert result == 2, "验证失败"

        with allure.attach(name="截图", body="这是一个截图文件的内容"):
            # 这里可以添加截图相关的代码,例如:/Users/may/Downloads
            # allure.attach.file("screenshot.png", attachment_type=allure.attachment_type.PNG)
            pass

        with allure.attach(name="日志", body="这是一段日志信息"):
            # 这里可以添加日志相关的代码,例如:
            # allure.attach.file("log.txt", attachment_type=allure.attachment_type.TEXT)
            pass

运行结果