一、自定义Allure 报告logo图标

1.找到allure安装目录下的config/allure.yml,并打开编辑。

image-20250909090647680

2.在文件尾部添加:

- custom-logo-plugin

image-20250909090833709

3.找到allure安装目录下的plugins\custom-logo-plugin\static,将需要展示的 Logo 图片放进去

image-20250909091416388

4.修改 styles.css 文件:

image-20250909092945399

5.在pytest.ini文件中指定在reports/temps目录下生成Allure 报告,且在main.py中启动 allure 服务,直接在浏览器中预览测试报告

image-20250909093042113

image-20250909093200746

效果示例:

image-20250909093437046

二、Allure 报告个性化命名定制

  • 项目名称定制
@allure.epic("项目名")
  • 模块名称定制
@allure.feature("模块名称")
  • 接口名称定制
@allure.story("接口名称:登录")
  • 示例:

image-20250909102207326

image-20250909102238799

报告截图:

image-20250909102356346

  • title:标题,可以理解为用例名称

Allure 提供了 allure.dynamic 模块,支持在测试运行时动态修改用例标题。结合 caseinfo 中的 name 字段,可在测试方法中实时设置标题。

image-20250909110304664

报告截图:

image-20250909110343613