标签:
1.下载相关的jar包
2.获取到testlink的url和key,注意:url不是testlink的连接地址,是连接地址+/lib/api/xmlrpc.php
3.测试是否连接成功
public static void main(String args[]) { String url = "http://test.tl.gmsd.lan/lib/api/xmlrpc.php"; String devKey = "223f929e98e3d74fa3c000b67668e305"; TestLinkAPI api = null; URL testlinkURL = null; try { testlinkURL = new URL(url); } catch ( MalformedURLException mue ) { mue.printStackTrace( System.err ); System.exit(-1); } //api = new try { api = new TestLinkAPI(testlinkURL, devKey); } catch( Exception te) { te.printStackTrace( System.err ); System.exit(-1); } System.out.println(api.ping()); }
运行后,出现hello即表明连接成功
4. 更改测试用例执行结果
//获取测试计划id
Integer testPlanId = api.getTestPlanByName("新增还款方式(最新)", "交易系统").getId();
String buildName = "交易新增还款方式";
Integer testCaseId = 3734;
api.reportTCResult(testCaseId, null, testPlanId, ExecutionStatus.FAILED, null, buildName, "自动化上传结果的备注", null, null, null, null, null, null);
相关的用例id和buildname可以从导出的测试计划xml文件中得到。如下图
附录:
testlink常用的方法:http://testlinkjavaapi.sourceforge.net/implemented_methods.html
testlink接口:http://testlinkjavaapi.sourceforge.net/structure.html
标签:
原文地址:http://www.cnblogs.com/qiaoyeye/p/4608132.html