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

Serenity报告无法显示Scenario Outline场景详情,点击链接报错

问题描述

我创建了如下Cucumber Scenario Outline场景:

Scenario Outline: The one where we fetch classifications for a list of part numbers in batch from CCS
        Given the parts with classifications from CCS for plant XX
        When we lookup classifications for "KIC-OCS" plant IN/IT and classification region and type DE/IMPORT for effective date 06/23/2023 with derivations <derivationsEnabled> and the parts
       Then the classifications for the parts should be found  
         | Part Exists         |
         | <partExist>|
       Examples:
         | derivationsEnabled | partExist|
         | enabled            | true     |
         | disabled           | false    |

运行后,该场景会使用两组数据集执行,生成的Serenity报告中也显示了两个场景,但点击场景查看步骤详情时出现死链(文件未找到)。请问是否存在配置缺失?

使用的版本信息:

  • Gradle 7.4.2
  • 插件:id 'net.serenity-bdd.serenity-gradle-plugin' version '2.4.34'
  • cucumberVersion = '7.12.1'
  • serenityVersion = '3.9.7'
解决方案

以下是几个可能的原因及对应修复措施:

1. 版本兼容性问题

Serenity 3.9.7与Cucumber 7.12.1存在版本不匹配,这是导致报告路径映射异常的常见原因。根据Serenity官方版本矩阵,Serenity 3.9.x 建议搭配Cucumber 7.11.x版本。
修改build.gradle中的cucumberVersion为7.11.2,重新执行构建测试。

2. 报告生成任务配置缺失

确保build.gradle中正确配置Serenity报告输出路径及聚合任务,添加或完善以下配置:

tasks.withType(Test) {
    systemProperty "serenity.outputDirectory", "$buildDir/serenity-reports"
}

serenity {
    reports = ["single-page-html"]
    reportPath = "$buildDir/serenity-reports"
}

统一输出路径可避免报告文件路径错位,同时确保运行测试后执行aggregate任务整合报告:

./gradlew clean test aggregate

3. Gherkin场景格式错误

你的Then步骤中表格存在缩进和格式问题,可能导致Serenity无法正确解析场景实例。修正为:

Then the classifications for the parts should be found
  | Part Exists |
  | <partExist> |

保持步骤与表格的缩进一致,单元格对齐,避免语法解析异常。

4. 清理旧报告缓存

执行clean任务清除旧的构建产物和报告文件,再重新运行测试生成新报告,避免旧文件干扰:

./gradlew clean test aggregate

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 19:58:10