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

使用Cucumber自动化时Extent Report显示异常,该如何修复?

问题描述

在自动化测试中使用Cucumber框架,搭配Extent Report生成测试报告。测试执行完成后,report.html生成在target目录下,但打开报告时内容无法正常显示。

报告无法正常显示的截图

使用的Cucumber相关Extent Report依赖如下:

<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>

<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.2</version>
</dependency>
解决方案
  • 修正版本兼容性:cucumber-extentsreport 3.0.2与extentreports 3.1.2存在适配冲突,建议将extentreports版本降级至3.1.0,调整后的依赖示例:
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>

<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.0</version>
</dependency>
  • 校验配置文件完整性:确保extent-config.xml配置正确,重点检查主题、编码、资源路径等设置,避免因资源加载失败导致页面空白。示例配置片段:
<extentreports>
  <configuration>
    <theme>standard</theme>
    <documentTitle>自动化测试报告</documentTitle>
    <reportName>Cucumber测试报告</reportName>
    <encoding>UTF-8</encoding>
  </configuration>
</extentreports>
  • 通过本地服务器打开报告:部分浏览器会限制本地HTML文件加载关联CSS/JS资源,导致内容无法渲染。可进入target目录后启动简易Web服务器:
python -m http.server 8000

随后在浏览器访问http://localhost:8000/report.html。

  • 清理旧报告重新生成:删除target目录下的旧报告文件及缓存,重新执行测试用例生成新报告,避免旧文件损坏引发的显示异常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 17:15:40