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

Jenkins执行Serenity Cucumber项目时JUnit JSON报告兼容问题排查

Fixing Serenity Cucumber JSON/JUnit Report Issue for qTest Integration

Let's walk through resolving your problem step by step—your core issue stems from misconfigured report generation and mismatched report formats expected by qTest:

What Went Wrong

Your current Cucumber runner configuration has a critical mistake:

plugin = { "pretty", "junit:target/cucumber-reports/Cucumber.json" }

The junit: prefix tells Cucumber to generate JUnit XML format reports, but you've saved it to a .json file. So you end up with an XML file disguised as JSON, which explains why qTest throws that error—it tries to parse XML content as JSON and fails.

Additionally, the Serenity-generated JSON files in target/site/serenity are Serenity's proprietary format, not the standard Cucumber JSON or JUnit JSON that qTest expects.

Step 1: Generate Proper Cucumber JSON Reports

First, fix your runner class to generate a genuine Cucumber JSON report (which includes full Gherkin steps) alongside optional JUnit XML reports:

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
    features = "src/test/resources/features",
    glue = "com.your.stepdef.package",
    plugin = {
        "pretty",
        "json:target/cucumber-reports/Cucumber.json", // Generates valid Cucumber JSON with Gherkin steps
        "junit:target/cucumber-reports/Cucumber.xml"  // Optional: Standard JUnit XML if needed elsewhere
    }
)
public class YourTestRunner {}

After running the build, check target/cucumber-reports/Cucumber.json—it should be valid JSON with your Feature, Scenario, and Step details.

Step 2: Configure Jenkins qTest Plugin to Use the Correct Report

Next, update your Jenkins project's qTest configuration:

  • Set the test result location to target/cucumber-reports/Cucumber.json (not the Serenity JSON path)
  • If qTest doesn't natively support Cucumber JSON format:
    • Use a Jenkins plugin like the Cucumber Reports Plugin to process the JSON first, then configure qTest to pick up the converted output
    • Or add a build step to run a conversion tool (e.g., a simple Java utility or jq script) to transform Cucumber JSON into a format qTest accepts

Step 3: Verify the Fix

Run your Jenkins job again, then:

  1. Confirm target/cucumber-reports/Cucumber.json is valid JSON (open it in a text editor to check)
  2. Check qTest logs—you should no longer see the "Failed to read..." error, and test results with full Gherkin steps should be imported successfully

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 08:34:29