Open romedtino opened 1 year ago
Hello @romedtino
Updating test cases is not currently supported by the TestRail CLI, but thanks for raising this issue. I'll tag it as an enhancement to be potentially analyzed for a future release.
Cheers
No problem. If anyone is interested, I kludged source and modified trcli/trcli/api/api_request_handler.py
where I add this tidbit in line 305
if test_case["case_fields"]:
new_refs = test_case["case_fields"]["refs"]
if new_refs != case["refs"]:
payload = {
"case_id": case["id"],
"refs": new_refs
}
response = self.client.send_post(f"update_case/{case['id']}", payload)
print(response)
This will override refs if the new one coming in is different from what existed.
No problem. If anyone is interested, I kludged source and modified
trcli/trcli/api/api_request_handler.py
where I add this tidbit in line 305if test_case["case_fields"]: new_refs = test_case["case_fields"]["refs"] if new_refs != case["refs"]: payload = { "case_id": case["id"], "refs": new_refs } response = self.client.send_post(f"update_case/{case['id']}", payload) print(response)
This will override refs if the new one coming in is different from what existed.
Maybe create a PR and owners can merge so we can all benefit. I have exact same problem.
I unfortunately don't work for the company I did this for anymore. Though I do still keep in contact with old coworkers that might be willing to do just that. But the source is up there and I'm not 100% convinced it's the best approach. It probably needs more brains, how to deal with existing, append/overwrite, cli options? š¤·
TestRail CLI Version
1.4.2
CLI Environment
Mac OS Ventura 13.1, Python 3.11.1
TestRail Version
6.6.1.1166
TestRail Instance Type
Enterprise Server
Current behavior
In a pytest junitxml generated report, having property
testrail_case_field
valuerefs:REF-123
will not update the references of a case if it exists. If the case does not exist,trcli
creates the test case and will contain the reference.Desired behavior
Having property with
refs
should update existing casesMore Details
I currently have a very basic pytest script that uses
--case-matcher property
to match case IDs and if a given case exists, havingrecord_property("testrail_case_field", "refs:PRJCT-1234")
fails to add the reference to the existing case.Sample pytest script - name to
test_sample.py
running with
pytest --juinitxml "junit-report.xml"
generates something like-Then invoking trcli with it
It reports success and when I look at the TestRail site, I see it add a new testcase for
test_sample_not_existing
with the correct References but when I look at case C1234, the Reference value is still None. Is this expected behavior for cases that exist that you can't update refs through a test run? Thanks!