Skip to content

Support for update test result from one testcase cover/mapping to multiple test_ids #343

@kakarot9x

Description

@kakarot9x

What would you like the TestRail CLI to be able to do?

This is not new, see: Need support for adding multiple testrail case IDs in single test but it is really, really useful to everyone.

21:18:03 ~\.venv\Lib\site-packages\trcli\readers\junit_xml.py", line 115, in _extract_case_id_and_name
21:18:03      case_id = int(prop.value.lower().replace("c", ""))
21:18:03  ValueError: invalid literal for int() with base 10: '123,456,789'

Right here, in case there is any "," in the case_id, we can split them out to a list of int and process one by one easily.

Why is this feature necessary on the TestRail CLI?

For example I have one test case, cover for 3 test_ids as below in the junit.xml

<testcase classname="tests.test_abc" name="test_abc_xyz" time="5.0">
 <properties>
  <property name="test_id" value="C123, C456, C789"/>
 </properties>

It is much more helpful when we have one test script to cover for multiple test_id with parameterize input.
So why don't we support it?

More details

I refer to support this format:

<properties>
  <property name="test_id" value="C123, C456, C789"/>
</properties>

Instead of this one:

<properties>
  <property name="test_id" value="C123"/>
  <property name="test_id" value="C456"/>
  <property name="test_id" value="C789"/>
</properties>

But both of them should be enable and working

My proposal:

# Code to process case_ids
case_ids = []  # Initialize an empty list
case_name = case.get('name')

prop = self._find_property(case, self.case_id_field)
if prop is not None and prop.value:
    # Clean the string and split by comma to get a list of ID strings
    id_strings = prop.value.lower().replace("c", "").split(',')
    
    for id_str in id_strings:
        try:
            # For each string, strip whitespace and try converting to an int
            clean_id_str = id_str.strip()
            if clean_id_str: # Ensure it's not an empty string
                case_ids.append(int(clean_id_str))
        except ValueError:
            # If a part isn't a valid number, just skip it and continue
            continue
            
return case_ids, case_name  # Return the list of IDs and the name
# Code to parse_test_cases
def _parse_test_cases(self, suite: Element) -> list[TestCase]:
    test_cases: list[TestCase] = []
    for case in suite.iter('testcase'):
        # This now returns a LIST of IDs, e.g., [50110361, 50110353]
        case_ids, case_name = self._extract_case_id_and_name(case)
        
        # If the list is empty, skip to the next <testcase>
        if not case_ids:
            continue
            
        # Get other details once
        status_id = self._get_status(case)
        elapsed = self._get_elapsed(case)
        comment = self._get_comment(case)
        defects = self._get_defects(case)

        # Loop through each ID found for this test case
        for case_id in case_ids:
            test_case = TestCase(
                case_id=case_id,  # Use the individual ID from the list
                title=case_name,
                status_id=status_id,
                comment=comment,
                elapsed=elapsed,
                defects=defects
            )
            test_cases.append(test_case)
            
    return test_cases

Interested in implementing it yourself?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    New FeatureNew feature or requestTriageThis issue currently being reviewed by the TestRail team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions