如何在Endly中生成供Jenkins解析查看的XML测试结果报告?
Got it, let's break down how to generate Jenkins-compatible XML test reports with Endly step by step. Jenkins natively works with JUnit-style XML reports, so we'll focus on configuring Endly to output results in that standard format—no extra conversion tools needed.
Jenkins relies on JUnit XML as the standard for parsing test results. This format uses <testsuite> and <testcase> tags to encapsulate test runs, failures, errors, and execution times. Endly has built-in support for generating this exact format, so we just need to tell it to use it.
You can set this up either via an Endly workflow YAML file or directly via the command line.
Option 1: Use a Workflow YAML File
Create (or modify) your test workflow file (e.g., test-workflow.yaml) to include a report block specifying the JUnit type and output path:
pipeline: run-tests: action: tester:run tests: ["tests/**/*.test"] # Path to your Endly test files report: type: junit output: ./build/test-results/junit-report.xml # Where to save the XML report
To execute this workflow, run:
endly run -f test-workflow.yaml
Option 2: Command Line Execution
If you prefer running tests directly without a workflow file, pass the report parameters as flags:
endly run tester:run -tests="tests/**/*.test" -report.type=junit -report.output=./build/test-results/junit-report.xml
This will execute your tests and dump the JUnit XML report to the specified path immediately.
After running the tests, check the output file to ensure it follows the JUnit structure. A valid report should look something like this:
<testsuite name="UserServiceTests" tests="3" failures="1" errors="0" skipped="0" time="0.25"> <testcase name="TestCreateUser" classname="UserServiceTest" time="0.08"/> <testcase name="TestGetUser" classname="UserServiceTest" time="0.05"/> <testcase name="TestDeleteUser" classname="UserServiceTest" time="0.12"> <failure message="User not found after deletion"/> </testcase> </testsuite>
If you see this structure, you're good to go—Jenkins will recognize it.
Once Endly generates the XML, you need to tell Jenkins to pick it up:
- Go to your Jenkins project configuration
- Scroll to the Post-build Actions section
- Add the Publish JUnit test result report action
- In the "Test report XMLs" field, enter the path to your Endly-generated report (e.g.,
**/build/test-results/junit-report.xml—use glob patterns if you have multiple reports) - Save the configuration
Next time you run the Jenkins build, it will parse the XML report and display test stats, failure details, and historical trends right in the Jenkins UI.
- Jenkins can't find the report: Double-check the path in Jenkins matches where Endly saved the file. Ensure the build step runs Endly before the report publishing step.
- Invalid XML format: Make sure you're using a recent version of Endly—older versions might not support JUnit report generation correctly. If you customized the report, verify all tags follow JUnit standards.
- Missing test data: If the report is empty, confirm your Endly tests are actually running (check the Endly logs) and that the test path in your configuration is correct.
内容的提问来源于stack exchange,提问作者A. Hunt

