Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to link one automated test to multiple test cases by name or property #133

Closed
ssv-w32 opened this issue Feb 27, 2023 · 3 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@ssv-w32
Copy link

ssv-w32 commented Feb 27, 2023

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

I'd like to be able to add multiple test cases in run result like this:

--case-matcher "property"

        <testcase classname="tests.whatever"
                  name="test_create_whatever"
                  time="31.917">
            <properties>
                <property name="test_id" value="C1"/>
                <property name="test_id" value="C2"/>
                <property name="test_id" value="C3"/>
            </properties>
        </testcase>

OR

--case-matcher "name"

        <testcase classname="tests.whatever"
                  name="C1_C2_C3_test_create_whatever" time="31.917" >
        </testcase>

Why is this feature necessary on the TestRail CLI?

I want it because I have automated tests that cover >1 test case from TestRail as part of one test.

More details

No response

Interested in implementing it yourself?

No

@ssv-w32 ssv-w32 added the enhancement New feature or request label Feb 27, 2023
@ssv-w32
Copy link
Author

ssv-w32 commented Feb 28, 2023

this could be possible solution for properties

diff --git a/trcli/readers/junit_xml.py b/trcli/readers/junit_xml.py
index 4475193..4572695 100644
--- a/trcli/readers/junit_xml.py
+++ b/trcli/readers/junit_xml.py
@@ -77,7 +77,7 @@ class JunitParser(FileParser):
                         processed_section_properties.append(prop.name)
                 for case in section:
                     cases_count += 1
-                    case_id = None
+                    multiple_ids = []
                     case_name = case.name
                     attachments = []
                     result_fields = []
@@ -90,7 +90,7 @@ class JunitParser(FileParser):
                     for case_props in case.iterchildren(Properties):
                         for prop in case_props.iterchildren(Property):
                             if prop.name and self.case_matcher == MatchersParser.PROPERTY and prop.name == "test_id":
-                                case_id = int(prop.value.lower().replace("c", ""))
+                                multiple_ids.append(int(prop.value.lower().replace("c", "")))
                             if prop.name and prop.name.startswith("testrail_attachment"):
                                 attachments.append(prop.value)
                             if prop.name and prop.name.startswith("testrail_result_field"):
@@ -109,27 +109,28 @@ class JunitParser(FileParser):
                     if error:
                         self.env.elog(error)
                         raise Exception(error)
-                    result = TestRailResult(
-                        case_id,
-                        elapsed=case.time,
-                        junit_result_unparsed=case.result,
-                        attachments=attachments,
-                        result_fields=result_fields_dict
-                    )
-                    for comment in reversed(comments):
-                        result.prepend_comment(comment)
-                    if sauce_session:
-                        result.prepend_comment(f"SauceLabs session: {sauce_session}")
-                    test_cases.append(
-                        TestRailCase(
-                            section.id,
-                            case_name,
-                            case_id,
-                            result=result,
-                            custom_automation_id=automation_id,
-                            case_fields=case_fields_dict
+                    for single_id in multiple_ids:
+                        result = TestRailResult(
+                            single_id,
+                            elapsed=case.time,
+                            junit_result_unparsed=case.result,
+                            attachments=attachments,
+                            result_fields=result_fields_dict
+                        )
+                        for comment in reversed(comments):
+                            result.prepend_comment(comment)
+                        if sauce_session:
+                            result.prepend_comment(f"SauceLabs session: {sauce_session}")
+                        test_cases.append(
+                            TestRailCase(
+                                section.id,
+                                case_name,
+                                single_id,
+                                result=result,
+                                custom_automation_id=automation_id,
+                                case_fields=case_fields_dict
+                            )
                         )
-                    )
                 test_sections.append(
                     TestRailSection(
                         section.name,

@mnataraj17
Copy link

mnataraj17 commented Feb 28, 2023

It's a Duplicate of #130
It would be great if someone could consider this. Lot of organizations follow this pattern of having multiple testrail cases in one Automated test in order to make tests more efficient. Thanks!

@d-rede d-rede added the duplicate This issue or pull request already exists label Sep 5, 2023
@d-rede
Copy link
Contributor

d-rede commented Sep 5, 2023

Thanks for your feedback. I'm closing this issue since it's a duplicate, but we will follow-up on #130.

@d-rede d-rede closed this as completed Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants