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

List all the Test cases in the Test plan using python script


#1

Hi
Is there a way to list down all the test cases tagged to a Test plan using python. it is from the test plan id i must list down all the test cases involved in the test plan

Thanks


#2

Hi Prabhu,

You can use Python along with the TestRail API. We provide a Python API ready to use wrapper that you can leverage for this as well. You can find documentation and the script here:

http://docs.gurock.com/testrail-api2/bindings-python

Our API documentation can be found here as well:

http://docs.gurock.com/testrail-api2/start


#3

Hi
Thanks you so much for the reply… I am already using the API but i am not able to list down the test cases for a Test plan which has sub test plan. Is there a way by which i can list down the test cases for a Test plan that has sub test plans

currently i am using get_from_TR(“get_plans”,test palin id) in my script, But i am not able to list down all the test cases that are planned for this test plan…

Thanks once again for your reply


#4

Hi there,

No problem. I believe you are referring to this setup:

Project

  • Test Plan
    – Test Run
    – Test Run

Is this correct? If not, please let me know. If this is correct, then you could utilize the following methods:

  • get_plans
  • get_runs

http://docs.gurock.com/testrail-api2/reference-plans#get_plans
http://docs.gurock.com/testrail-api2/reference-runs#get_runs


#5

Hi
I used get_runs with project id and i am not able to list down the runs for the project.

The api document says it can only return those test runs that are not part of a test plan.

Am i missing anything ?

Can i get the test cases list if i give the test run manually ?


#6

Hi there,

The get_runs method will only give you runs that are not part of a test plan. This is correct. If you are using get_plans along with get_plan for a specific plan, you will get a list of runs that are included in that plan. You can then use the get_run method to grab information specific to a single run.


#7

Hi
I got it working… Thank you so much for your support. :slight_smile:


#8

Perfecto! Glad I was able to help you out. Let us know if you need any other assistance.


#9

In the solution you are suggesting, where do you find the list of runs that are included in the plan you want? Given that you want to list all the test cases within a specific plan such as:

Project

  • Test plan
    – Test run
    – Test run

Could you please provide example?


#10

Hi there,

In this case you would simply use the get_plan or get_plans methods. get_plans would return a list of all plans. get_plan would return information regarding the specific plan including run information.

http://docs.gurock.com/testrail-api2/reference-plans