parse_junit section handling logic #311
-
Hi folks, I'm using trcli to run this command (sensitive values redacted):
The team using this project does not use suites, so the project has one "Master" suite and several sections within the suite. I believe this suite is created by default when the project is created--no one seems to know who created it. The JUnit report has 3 tests, using the name case matcher, that are all part of the same section. Test runs are being created successfully and the tests are showing as part of the correct section. My question is: how are they showing up as part of the correct section? It looks like trcli has some logic to figure it out but I haven't been able to find it in the code. This is a snippet of my JUnit report: <testsuites id="14898" name="" tests="3" failures="1" skipped="0" errors="0" time="9.153922">
<testsuite name="nameMethodExample.spec.ts" timestamp="2025-06-11T20:13:29.354Z" hostname="nameMethodTests" tests="3" failures="1" skipped="0" time="6.435" errors="0">
<testcase name="C14716232 - Should load the example website and check title" classname="nameMethodExample.spec.ts" time="0.527"> </testcase>
... Following the documentation about how JUnit maps to TestRail here: https://github.com/gurock/trcli?tab=readme-ov-file#junit-xml-report-example
{'id': 2045143, 'suite_id': 14898, 'name': 'nameMethodExample.spec.ts', 'description': None, 'parent_id': None, 'display_order': 164, 'depth': 0} What I don't understand is when/how TestRail figures out that the name of the section is actually "Testing Adding Defect from Test Results" and not the value in the report, which it does because the test run has the correct section name. If I do a GET get_sections API directly, I get this, which has the actual section name: {
"id": 1878393,
"suite_id": 14898,
"name": "Testing Adding Defect from Test Results",
"description": null,
"parent_id": null,
"display_order": 8,
"depth": 0
}, Is the trcli handling this or does TestRail just ignore the incorrect payload. Just wanting to understand it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This issue was bothering me, so last night I took some time to dig into it further. What I found through experimentation is that no suite id or name is needed at all in the JUnit report. When I run <testsuites id="" name="" tests="1" failures="0" skipped="0" errors="0" time="1.1748139999999998">
<testsuite name="suiteIdTests.spec.ts" timestamp="2025-06-12T22:03:17.196Z" hostname="suiteIdTests" tests="1" failures="0" skipped="0" time="0.477" errors="0">
<testcase name="C25966687 - Should load the example website and check title" classname="suiteIdTests.spec.ts" time="0.477">
</testcase>
</testsuite>
</testsuites> In fact, it seems like suites and sections are the same entity that are displayed slightly differently in the UI. Considering that it's not necessary to pass either one in the JUnit report, the Junit to TestRail mapping is confusing. I'm hoping someone can provide clarity around the behavior and let me know whether this is correct/expected. |
Beta Was this translation helpful? Give feedback.
Hi @cgeisel, In single-suite TestRail projects, you don’t need to include suite info in the JUnit XML. Also:
This behavior is correct and expected — suites and sections are separate, but the UI in single-suite mode can make them appear similar. Thank you.