標籤:
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
java如何串連testlink