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

Allow custom result fields - passed up on results for cases #112

Closed MattKiazyk closed 1 year ago

MattKiazyk commented 1 year ago

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

Solution description

When posting test case results back to TestRail there are often times where we want to pass up custom fields to populate. This adds the ability to set those custom results

Changes

Adds a new --result-fields property to the parse_junit command similar to how --case-fields works. If added, these will get applied to the add_results_for_cases api call.

In the below example

trcli -y -v \
...
parse_junit \
--run-id 146 \
--suite-id 33 \
--result-fields custom_env:1 \
--file report.junit

adds in the custom_env property to the call:

url: https://xxx/index.php?/api/v2/add_results_for_cases/146
payload: {'results': [{'case_id': 61, 'status_id': 1, 'comment': '', 'elapsed': '1s', 'attachments': [], 'custom_env': '1'}, {'case_id': 147, 'status_id': 5, 'comment': 'Type: \nMessage: failed - Error starting virtual visit invalidRequest(message: "Invalid data sent")\nText: \n        baseIntegrationTests.swift:412\n      ', 'attachments': [], 'custom_env': '1'}, {'case_id': 142, 'status_id': 1, 'comment': '', 'elapsed': '6s', 'attachments': [], 'custom_env': '1'}]}
response status code: 200

Steps to test

Add a --result-fields custom_env:1 to the call including a -v to see the new property being added to the add_results_for_cases api call.

PR Tasks

d-rede commented 1 year ago

@MattKiazyk thank you so much for your contribution! 💪

This will be merged onto the next release branch which is soon to be published.