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

Cucumber 7.0.0版本Masterthought测试报告无法生成如何解决

修复方案

核心问题

你当前TestRunner配置中dryRun=true,该参数仅校验步骤匹配性不会执行实际测试,导致生成的cucumber.json为空,Masterthought插件读取不到有效报告内容触发报错。


问题1:Cucumber 7.0.0 生成Masterthought报告的标准配置

测试运行器配置

必须关闭dryRun,配置正确的json输出路径,示例如下:

@RunWith(Cucumber.class)
@CucumberOptions(
        features="src/test/resources/features",
        glue= "stepdefinitions",
        dryRun=false,
        monochrome=true,
        plugin= {"pretty","json:target/cucumber/cucumber.json"}
)
public class TestRunner {
}

POM依赖&插件配置

  • 所有io.cucumber开头的依赖版本统一为7.0.0
  • 移除废弃依赖cucumber-jvm-deps,Cucumber 7.x已整合相关能力无需单独引入
  • net.masterthought maven-cucumber-reporting 5.6.2版本和Cucumber7兼容,可正常使用
  • 插件配置中inputDirectory设为${project.build.directory},json文件匹配规则**/cucumber*.json是正确的,无需调整

问题2:当前依赖的冲突排查

你的依赖存在2个非冲突但不合理的配置,调整即可:

  • 删除cucumber-jvm-deps依赖,该依赖已经废弃,强行引入可能引发类加载冲突
  • 将cucumber-testng的scope从compile调整为test,符合测试依赖的生命周期规范
  • 其余依赖(selenium 4.0.0、log4j 2.14.1、fillo 1.21)和当前版本栈无冲突

执行修复

完成上述调整后,执行mvn clean verify即可正常生成Masterthought报告。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 02:54:00