gurock / trcli

TR CLI (trcli) is a command line tool for interacting with TestRail.
Mozilla Public License 2.0
48 stars 39 forks source link

Add --case-matcher name_skip_unknown option #147

Closed Booklynn closed 11 months ago

Booklynn commented 1 year ago

Issue being resolved: https://github.com/gurock/trcli/issues/148

Solution description

How are we solving the problem? When attempting to add test results from the junit.xml file, if one of the test names includes an invalid or unknown case ID (CXXX) that is not present in TestRail's test suite under the specified test run, the --case-matcher name command cannot be used. In such a situation, the command will abort and display the message "Case CXXX is unknown or not part of the test run." Therefore, I have created a new case-matcher specifically designed for this situation.

Changes

What changes were made?

  1. in trcli\api\api_request_handler.py, I added new condition elif self.environment.case_matcher == MatchersParser.NAME_SKIP_UNKNOWN:
  2. in trcli/commands/cmd_parse_junit.py, I added type=click. Choice(["auto", "name", "property", "name_skip_unknown"], case_sensitive=False),
  3. in trcli/data_classes/data_parsers.py, I added NAME_SKIP_UNKNOWN = "name_skip_unknown"
  4. in trcli/readers/junit_xml.py, I added new condition elif self.case_matcher == MatchersParser.NAME_SKIP_UNKNOWN:

Potential impacts

What could potentially be affected by the implemented changes?

Steps to test

Happy path to test implemented scenario

  1. Create a test run that includes a single test suite.
  2. Within the test suite, include two test cases.
  3. Update the junit.xml file to include the names of the two tests.
  4. Ensure that one of the test names in the junit.xml file matches the test name specified in the test suite.

PR Tasks