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

TestRail API - Need help in creating test runs inside test plans (using Python)



I am working on automating testrail areas for our project. So our flow is Milestone > Test Plan > Test Run 1 / Test Run 2 / …

I am trying to automate the above workflow using TestRail API. I am able to add test runs (on individual test suites) inside Test Plan using “add_plan_entry” method. I would like to know if there is an option for me to have restrict test cases that are getting added to test run based on priority (say I want only “Blocker” tests in my test run).

We can do this by passing the individual test case ids but I would like to know if there is any other options available


Hi Ganesh,

Thanks for your posting. The add_plan/add_plan_entry would accept the case selection via include_all/case_ids. You can add a few additional calls to find the case selection based on filters and custom criteria. For example, you can find all cases with a specific priority as follows (expects the priority IDs):


There are additional filters for built-in system fields:

(see Request filters)

You can implement additional filters on the client-side. Once you have the list of cases you would like to include, you can pass the case IDs to add_plan or add_plan_entry (with include_all = false).

I hope this helps!



Thanks Tobias for quick response. This is really helpful.

Also is there a possibility for me to use ‘label’ in request filter? Say I want to filter cases of
-priority id (1)
-contains label “Windows 7”
-contains label “FireFox”



Hi Ganesh,

The request filter on the server wouldn’t support this directly but you can use the priority filter and then filter the list further on the client side (in your code).

I hope this helps!