您的位置:軟件測試 > 開源軟件測試 > 開源測試管理工具 > Testlink
Python之TestLink模塊
作者:sammy1989 發(fā)布時間:[ 2017/5/19 9:40:03 ] 推薦標(biāo)簽:測試管理工具 Testlink

  1.安裝:pip install TestLink-API-Python-client
  2.Python連接上TestLink:

1 import testlink
2
3 url = 'http://10.138.30.4:82/testlink/lib/api/xmlrpc/v1/xmlrpc.php'
4 key = '14115ec841a5c22a5b095158d2eb7'
5
6 tlc = testlink.TestlinkAPIClient(url, key)
  3.獲取TestLink上的信息:
1 def get_information_test_project():
2     print("Number of Projects      in TestLink: %s " % tlc.countProjects())
3     print("Number of Platforms  (in TestPlans): %s " % tlc.countPlatforms())
4     print("Number of Builds                   : %s " % tlc.countBuilds())
5     print("Number of TestPlans                : %s " % tlc.countTestPlans())
6     print("Number of TestSuites               : %s " % tlc.countTestSuites())
7     print("Number of TestCases (in TestSuites): %s " % tlc.countTestCasesTS())
8     print("Number of TestCases (in TestPlans) : %s " % tlc.countTestCasesTP())
9     tlc.listProjects()
  4.獲取test suite:
1 def get_test_suite():
2     projects = tlc.getProjects()
3     top_suites = tlc.getFirstLevelTestSuitesForTestProject(projects[0]["id"])
4     for suite in top_suites:
5         print (suite["id"], suite["name"])
  5.創(chuàng)建測試用例集:
1 def create_test_suite(project_id, test_suite_name, test_suite_describe, father_id):
2     if father_id == "":
3         tlc.createTestSuite(project_id, test_suite_name, test_suite_describe)
4     else:
5         tlc.createTestSuite(project_id, test_suite_name, test_suite_describe, parentid=father_id)
  6.創(chuàng)建測試用例:
1 def create_test_case(father_id, data):
2     tlc.initStep(data[0][2], data[0][3], automation)
3     for i in range(1, len(data)):
4         tlc.appendStep(data[i][2], data[i][3], automation)
5     tlc.createTestCase(data[0][0], father_id, "1", "timen.xu", "", preconditions=data[0][1])
  7.獲取測試用例:
1 def get_test_case(test_case_id):
2     test_case = tlc.getTestCase(None, testcaseexternalid=test_case_id)
3     for i in test_case:
4         print ("序列", "執(zhí)行步驟", "預(yù)期結(jié)果")
5         for m in i.get("steps"):
6             print (m.get("step_number"), m.get("actions"), m.get("expected_results"))
  8.發(fā)送測試結(jié)果給TestLink:
1 def report_test_result(test_plan_id, test_case_id, test_result):
2     tlc.reportTCResult(None, test_plan_id, None, test_result, "", guess=True,
3                        testcaseexternalid=test_case_id, platformname="0")
  備注:發(fā)送測試結(jié)果給TestLink,1.9.14版本暫時不支持每個步驟的結(jié)果反饋,下一個版本1.9.15可支持每個步驟結(jié)果反饋。

軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd