Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

Need to update the test run with few more test cases and teh results of the previous testcases should be there

I have 100 testcases in my existing testrun with existing results updated. Now I want to add 50 more test cases to this test run. So at the end I should have 150 test cases(100 should retain their results and 50 should not have any results). When I am trying to update the test run with update _run api, the 100 test cases are getting vanished and run is getting created with new 50 testcases.
Please help

Please find below the script , I am using

from testrail import *
import pandas as pd
import ConfigParser
Config = ConfigParser.ConfigParser()“auth.ini”)

def ConfigSectionMap(section):
dict1 = {}
options = Config.options(section)
for option in options:
dict1[option] = Config.get(section, option)
if dict1[option] == -1:
print(“skip: %s” % option)
print(“exception on %s!” % option)
dict1[option] = None
return dict1

client = APIClient(’<my company path’)
client.user = ConfigSectionMap(“TestRailLogin”)[“username”]
client.password = ConfigSectionMap(“TestRailLogin”)[“password”]
project_name = ConfigSectionMap(“TestRailLogin”)[“projectname”]
suite_id = ConfigSectionMap(“TestRailLogin”)[“suiteid”]

if client.user == “” and client.password == “”:
print(“Kindly update your credentials in auth.ini and retry”)

def get_project_id():
Returns the id of the project
:param projectname:
:return: id of the project
project_id = None
projects = client.send_get(‘get_projects’)
for project in projects:
if project[‘name’]==project_name:
project_id = project[‘id’]
return project_id

#df = pd.read_excel(’/Users/Documents/Daily_run_test_cases copy.xlsx’, sheetname=0)

request_string = ‘update_run/12345’
data = {“include_all”:False, “case_ids” :[“3930710”]}
cases = client.send_post(request_string,data)
if cases:

I already have 100 test cases in 12345 run, but I want to update it with one more case_id ie. 3930710. Now when I run teh above code , all teh 100 testcases are getting vanished and only one test case is seen in run12345. pls help

@tgurock can you pls help me with this.

just as an FYI - the Gurock’s are no longer affiliated with the company.

ok. Thanks. Then who is the best one to contact

Hey Valli,

Thanks for the post! When using the update_run method to add additional test cases you would need to run have the request include all IDs, including those already in the test run, within the API call. For instance I have a test run with ID 321 that includes test case IDs 1, 2, 3, 4, and 5, and I’ve already added results to them. Now, I want to update it to include 6, 7, 8, 9, and 10. If I run the api call with the case_ids array only populated with the second set of case IDs, the system will remove all other test cases from the run that do not match those IDs. I would need to include the full array of all test cases that are already present, then append any additional cases I’d like to add into the run.

One thing to note, if you try the API call again with the full list of test case IDs present, the original tests will be added back into the test run with any result data intact. So going back to the example above, if I have a test run with IDs 1-5 present and results added, then update it with "case_ids": [6, 7, 8, 9, 10] those tests will no longer be present. If I then re-run the update_run method with the full array using "case_ids": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] it will not only add those test cases back in, but all the previously recorded results data will still be present.

I hope that clarifies things a bit! On a different note, BGanger is correct, the Gurock brothers are no longer affiliated with TestRail support. However, we do have a rotating support team to monitor the forums here, and we are always available to reach directly at Don’t hesitate to let us know if you have any further questions.

Thanks a lot. This worked. big releif

Glad to hear it! We’ll be here if you have any further questions.