You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cucumber报告文件名缺失tag-name/feature-name仅显示数值问题咨询

问题说明

Cucumber报告文件名未包含tag-name或feature-name,仅显示无对应标签标识的数值,属于运行配置参数缺失导致的异常。

修复方案

1. Java生态(JUnit/TestNG集成Cucumber)

在测试启动类的@CucumberOptions注解中配置plugin参数,使用官方内置占位符拼接报告文件名,示例代码:

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/test/resources/features",
        glue = "com.your.project.stepdef",
        plugin = {
                "json:target/cucumber/cucumber.json",
                // 配置html报告命名规则,嵌入tag和feature名称占位符
                "html:target/cucumber/report-<tagName>-<featureName>.html"
        }
)
public class CucumberTestRunner {
}

2. 命令行直接运行Cucumber

在执行命令中通过--plugin参数指定报告命名规则,示例命令:

# 单标签运行示例
cucumber ./features --tags @TestTag --plugin html:./reports/report-<tagName>-<featureName>.html

3. 多标签/多feature批量运行适配

如果单次执行覆盖多个标签、多个feature文件,额外添加--naming-strategy long参数,避免报告重名覆盖,同时确保每个报告都能匹配到对应的标签和feature名称:

# 批量运行示例
cucumber ./features --plugin html:./reports/report-<tagName>-<featureName>.html --naming-strategy long

4. 配置校验

修改完成后重新执行测试,查看报告输出目录下的文件名是否已经正常拼接tag-name和feature-name即可。

内容的提问来源于stack exchange,提问作者user17513521

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 14:57:01