Python之TestLink模块

发表于:2017-5-18 11:42

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:sammy1989    来源:博客园

  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.创建测试用例
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.创建测试用例:
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 ("序列", "执行步骤", "预期结果")
5         for m in i.get("steps"):
6             print (m.get("step_number"), m.get("actions"), m.get("expected_results"))
  8.发送测试结果给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")
  备注:发送测试结果给TestLink,1.9.14版本暂时不支持每个步骤的结果反馈,下一个版本1.9.15可支持每个步骤结果反馈。
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号