lczub / TestLink-API-Python-client

A Python client to use the TestLink API
104 stars 63 forks source link

Is there any efficient way to get execution type of testcase? #103

Closed chintanvadgama closed 6 years ago

chintanvadgama commented 6 years ago

I would like to get all automated/manual cases for the test project. Currently, I am doing this in a very inefficient way.

EXECUTION_TYPES = {'manual': '1', 'automated': '2'}
project='test-project'
def getTestCasesByExecutionType(execType=''):
    testcases = []
    projID = tlapi.getTestProjectByName(project)['id']
    parent_ts = tlapi.getFirstLevelTestSuitesForTestProject(projID)[0]
    tcInfo = tlapi.getTestCasesForTestSuite(testsuiteid=parent_ts['id'],deep=True,details='full') #Have to call with details "full" as execution_type is only included in "full" details of testcase
    for each_tcInfo in tcInfo:
        if each_tcInfo['execution_type'] == EXECUTION_TYPES[execType.lower()]:
            testcases.append(each_tcInfo)
    return testcases

The above is not efficient solution as it has to get "full" details of each test case just to get the execution_type which takes a lot of time when number of testcases are in thousands. I would be grateful if you could point out any efficient method or other solution to determine execution_type.

lczub commented 6 years ago

Hello Chintan Vadgama ,

please apologize the last response. Have tried getTestCasesForTestPlan() ?

It has a several optional filter parameters

print(myTestLink.whatArgs('getTestCasesForTestPlan'))

getTestCasesForTestPlan(<testplanid>, [buildid=<buildid>], [platformid=<platformid>], [testcaseid=<testcaseid>], 
[keywordid=<keywordid>], [keywords=<keywords>], [executed=<executed>], [assignedto=<assignedto>], 
[executestatus=<executestatus>], [executiontype=<executiontype>], [getstepinfo=<getstepinfo>], 
[details=<details>], [devKey=<devKey>])
 List test cases linked to a test plan

        details - default is 'full', 
                  'simple', 'details' ??

        args variations:     keywordid - keywords 

I guess, your loop can be replaced with following two calls

tlapi.getTestCasesForTestPlan(projID, executiontype=1)
tlapi.getTestCasesForTestPlan(projID, executiontype=2)
chintanvadgama commented 6 years ago

thanks @lczub ..

I tried your method. For my specific end goal, that solution would not work as I had to get newly added "Automated" test cases from the Project and add it to the "Automation" testPlan.

Let's say, anyone within the team automates the testcase then one job will mark the testcase as "Automated" and another job will add all "Automated" testcases to "Automation" testplan. So, when we run our tests from CI, it will update the execution of "Automation" testplan.