—
前言
大家好,我是测试报告君。做测试报告分析4年,Allure是我最喜欢的报告框架。今天分享Allure报告的美化和定制技巧。
—
一、Allure报告结构
报告内容
Allure报告包含:
- 执行概览(成功/失败统计)
- 功能分类(按Feature分组)
- 时间统计(执行耗时分析)
- 详细信息(请求、响应、日志)
—
二、Allure注解使用
java
@Allure.Feature(“用户管理”)
@Allure.Story(“登录功能”)
@Allure.Title(“验证用户登录成功”)
@Allure.Severity(Allure.SEVERITY.CRITICAL)
public void testLoginSuccess() {
Allure.step(“打开登录页面”);
Allure.step(“输入用户名密码”);
Allure.step(“点击登录按钮”);
Allure.step(“验证登录成功”);
}
—
三、截图附件
java
// 失败时截图
@Attachment(value = “失败截图”, type = “image/png”)
public byte[] takeScreenshot() {
return ((TakesScreenshot)driver).getScreenshotAs(OutputType.BYTES);
}
—
总结
Allure报告美化要点:
| 要点 | 方法 |
|---|---|
| 分组 | @Feature、@Story注解 |
| 步骤 | Allure.step() |
| 附件 | @Attachment |
| 严重级别 | @Severity |
—
下期预告:数据驱动测试实战 – Excel、YAML、JSON多源数据管理