Open jazerix opened 9 months ago
I have added a test that validates the behavior described in the related issue and fixed in this PR.
I would also like to add, that I do not deem this to be the best solution. A better approach could be to allow for multiple case_ids within the TestRailCase
class - this would however require a substantial overhead to refactor the codebase. Magic methods could be used for backwards compatibility.
Alas, this solution is quite simple has the benefit that it does not affect the remaining codebase nor the logic herein :smile:
In the absence of staff reviewing, and having encountered the problem myself, I thought I'd have a go at reviewing the PR in hopes of expediting its inclusion.
I'm not sure that this fully resolves #130.
That ticket sites the example title= test_case_1 [C123 C456 C789]
This PR solves for XML with multiple automation_ids, but doesn't include name parsing, which is called in L120 of your modified junit_xml.py and would need to be modified to return multiple matches rather than a single (int,string).
HTH
In testcases where multiple properties has the
test_id
name, only the last value is persisted, which results in only one test being submitted and the previous ones being ignored.A problematic xml file could be structured as such:
When a JUnit XML file is ingested by the cli, it is parsed by the
parse_file
method found withinreaders/junit_xml.py
. During parsing, each element is iterated over. The parser attempt to extract thetest_id
and then and saves it to a global variablecase_id
, this has the downside that when the next element containing atest_id
name is read, it effectively overwrites the currentcase_id
.Issue being resolved: https://github.com/gurock/trcli/issues/130
Solution description
To solve this issue, I've introduced a global
copies
variable that "follows" the current case, such that it is automatically reset each time a new test case is being parsed. During parsing the parser now checks if thecase_id
is notNone
(indicating that thecase_id was set by another
test_id). In this event, the
test_idis added to the
copies` array.When the test case is done being parsed and is added to the list of tests cases (
test_cases
variable), the copies are iterated over and each create a deep copy of the currenttest_case
instance, alter their respective case_id and appends it to the list.This results in each test_id becoming an independent test and submitted to TestRail as such.
Changes
Altered
readers/junit_xml.py
:During parsing, now checks if the case id is already set:
Added
copy_coplicate_test_cases method
:Which is called when the parser is done parsing the case.
Potential impacts
The code added should not have any impact as it does alter the flow under the documented scenarioes (i.e. where one test case has one test_id).
All tests also pass.
Steps to test
Create an a junit test file where one testcase contains more than one test_id property.
PR Tasks