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

API: How to add test cases to an existing test run?


I want to add more test cases into the existing test run. How to do this using API?
I tried with update_run, but it just update the test cases by removing the older one. i want to retain the older one also.

Kindly assist


Hi Sanjay,

Thank you for the post. When you initially create your test run, are you creating this based on a specific section/suite of test cases? If you are adding additional test cases and then adding them to your test run you most likely have the selection set to a specific set. In your request you may also have includeall: false set which would only include the new test cases that you have added.

Your request could look like this:

“include_all”: false,
“case_ids”: [1, 2, 3, 5, 8]

Instead you can set this to true. This would include all test cases that were already included in your section/suite plus the additional test cases that you added. If you are staging your test run with a dummy test case ahead of time, you would want to make sure that the selection for the test run is set to include all test cases.

Hopefully this helps.


update_run does not work the way Marty described in the above post.

One. If you add a test to a test run like this:

“include_all”: false,
“case_ids”: [1, 2]

then call it again like this:

“include_all”: false,
“case_ids”: [3, 5, 8]

the test cases 1 and 2 will no longer be part of the run. They are overwritten.

Two. If you have a newly created test run and call update_run like this:

“include_all”: true,
“case_ids”: [1]

It will add testcase 1 to the testrun, but it will also add 2,3,5, and 8 if they are part of the same test suite.

There doesn’t seem to be an easy way to simply tack on another testcase to a testrun. I tried some code that first went out and got all of the existing test cases in a run, stepped through the resulting array and added each testcase ID to a list. Then I pushed the new testcase into that list and called update_run with include_all set to false.

This works in simple short runs, but it also creates a race condition if you’re running 100’s of tests that you want to add themselves to the test run so you’re going to end up missing some of them.

This one omission of being able to add a test case to a run easily really cripples the usefulness of the API for us. Now we’ll have to go through and create a list of tests manually that will have to be added to the newly created test run. This sort of defeats the purpose of the API in my view.

Alan Hatcher


Hi Alan,

Thanks for your reply and feedback! When specifying the case_ids in the update_run method, this would always set the case selection to what is included in the case_ids array. We would typically recommend using the get_tests method to retrieve the full list of tests in the run (and the response for this method would include the case_id field), and using this to build your update_run request. You would be able to get the full list of test cases and their IDs in this case, and then append any new test case_ids to the array in the update_run request. We’re also happy to look into simplifying this via request fields or similar for a future update to TestRail. Hope this helps!



Hi Marco,

I’m following the instructions you’ve provided here, but it seems like the new test cases are not being added to the test run. I’m using get_tests to retrieve the list of tests for the run, then appending the new test case ID to the case_ids field, and then posting with update_run with include_all set to false.

Going to try an approach by modifying the test suite and always using include_all = true to add test cases to a Test Run.


+1 for adding / removing test cases from existing testrun through API, without need to remove all / ad all functionality