Allure 报告工具
一个 WebdriverIO 报告插件,用于创建 Allure 测试报告。
安装
最简单的方法是将 @wdio/allure-reporter
作为 devDependency 包含在你的 package.json
中。
{
"devDependencies": {
"@wdio/allure-reporter": "^7.0.0"
}
}
你可以简单地通过以下方式安装:
npm install @wdio/allure-reporter --save-dev
配置
在你的 wdio.conf.js 文件中配置输出目录:
export const config = {
// ...
reporters: [['allure', {
outputDir: 'allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: true,
}]],
// ...
}
outputDir
默认为./allure-results
。测试运行完成后,你会发现该目录中包含每个规格的.xml
文件,以及一些.txt
和.png
文件和其他附件。disableWebdriverStepsReporting
- 可选参数(默认为false
),用于仅将自定义步骤记录到报告器中。issueLinkTemplate
- 可选参数,用于指定问题链接模式。报告器将用addIssue(value)
调用参数中指定的值替换{}
占位符。如果使用 Cucumber 并在任何级别设置了issue
标签,则应用相同的逻辑,它将在报告中转换为链接。参数值示例:https://example.org/issue/{}
tmsLinkTemplate
- 可选参数,用于指定 TMS(测试管理系统)链接模式。报告器将用addTestId(value)
调用参数中指定的值替换{}
占位符。如果使用 Cucumber 并在任何级别设置了testId
标签,则应用相同的逻辑,它将在报告中转换为链接。参数值示例:https://example.org/tms/{}
disableWebdriverScreenshotsReporting
- 可选参数(默认为false
),用于不将截图附加到报告器。useCucumberStepReporter
- 可选参数(默认为false
),使用 cucumber 时设置为 true 可以更改报告层次结构。自己尝试一下,看看效果如何。disableMochaHooks
- 可选参数(默认为false
),设置为 true 可以不将before/after
堆栈跟踪/截图/结果钩子获取到 Allure 报告器中。addConsoleLogs
- 可选参数(默认为false
),设置为 true 可以将步骤的控制台日志附加到报告器。reportedEnvironmentVars
(类型:Record<string, string>
) - 设置此选项以在报告中显示环境变量。请注意,设置此项不会修改实际的环境变量。