Jenkins执行Serenity Cucumber项目时JUnit JSON报告兼容问题排查
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
jqscript) to transform Cucumber JSON into a format qTest accepts
Step 3: Verify the Fix
Run your Jenkins job again, then:
- Confirm
target/cucumber-reports/Cucumber.jsonis valid JSON (open it in a text editor to check) - 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

