| Class | TestLinkClient |
| In: |
lib/TestLinkClient.rb
|
| Parent: | Object |
Author:: Sadahiko Hantani (garyohosu@gmail.com) Copyright:: Copyright (c) 2008 Sadahiko Hantani License:: Distributes under GPL 改定履歴
initialize
| server_url: | TestLink Server URL |
| dev_key: | Personal API access key |
| api_path: | xmlrpc.php path (Option) |
なし
TestLinkを設置したサーバーのURLとPersonal API access keyを設定します。 Personal API access keyを入手するには以下を実行してください。
/** SOAP API availability (disabled by default) */ $tlCfg->api_enabled = TRUE;
TestLinkを開き「Personal」を開く。 「Generate a new key」ボタンをクリック Personal API access key = xxxxxxxxxxxxxxxxxxxxxxxxxxxx
client = TestLinkClient.new("http://foo.org/testlink_18RC1","413a5f43341axxxxxx91f166501740ec")
# File lib/TestLinkClient.rb, line 52
52: def initialize(server_url,dev_key,api_path = "/lib/api/xmlrpc.php")
53: @server = XMLRPC::Client.new2(server_url + api_path)
54: @devKey = dev_key
55: end
about()
なし
"Testlink API Version: 1.0 Beta 3 written by Asiel Brumfield\n contribution by TestLink development Team"
Testlink APIの情報が返る
about() #=>Testlink API Version: 1.0 Beta 3 written by Asiel Brumfield\n contribution by TestLink development Team
# File lib/TestLinkClient.rb, line 535
535: def about
536: ret = @server.call("tl.about")
537: end
createBuild(testplanid,buildname,buildnotes)
| testplanid: | テスト計画ID |
| buildname: | ビルド名 |
| buildnotes: | ビルドノート |
例
[{"message"=>"Success!", "status"=>true, "id"=>"4"}]
テストプロジェクトID,ビルド名、ビルドノートを渡すと新規ビルドを生成する - :ビルドID name:ビルド名 notes:ノート id:ビルドID testproject_id:テストプロジェクトID active:アクティブか?
createBuild(testplanid,buildname,buildnotes) #=>[{"message"=>"Success!", "status"=>true, "id"=>"2"}]
# File lib/TestLinkClient.rb, line 221
221: def createBuild(testplanid,buildname,buildnotes)
222: args = {"devKey"=>@devKey,"testplanid"=>testplanid,"buildname"=>buildname,"buildnotes"=>buildnotes}
223: ret = @server.call("tl.createBuild",args)
224: end
createTestCase()
テストケース名を作成する(未実装)
createTestCase() #=>
# File lib/TestLinkClient.rb, line 461
461: def createTestCase()#未実装
462: args = {"devKey"=>@devKey}
463: ret = @server.call("tl.createTestCase",args)
464: end
createTestProject()
テストプロジェクトを作成する(未実装(引数不明))
createTestProject() #=>
# File lib/TestLinkClient.rb, line 484
484: def createTestProject()#引数不明
485: args = {"devKey"=>@devKey}
486: ret = @server.call("tl.createTestProject",args)
487: end
getBuildID(tpid)
| tpid: | テスト計画ID |
最も大きい(最新の)IDでアクティブでオープンなビルドID 例 3
最も大きい(最新の)IDでアクティブでオープンなビルドIDが返ります
getBuildID(tpid) #=>4
# File lib/TestLinkClient.rb, line 699
699: def getBuildID(tpid)
700: args = {"devKey"=>@devKey,"testplanid"=>tpid}
701: ret = @server.call("tl.getBuildsForTestPlan",args)
702: val = ret.select{|x|x["active"]=="1" and x["is_open"]=="1" }.sort{|a,b|a["id"].to_i<=>b["id"].to_i}
703: if not val.nil? then
704: return val[-1]["id"]
705: end
706: raise "BuildID error"
707: end
getBuildsForTestPlan(tpid)
| tpid: | テスト計画ID |
例
[{"name"=>"build1", "notes"=>"", "id"=>"1", "is_open"=>"1", "testplan_id"=>"3", "active"=>"1"}]
テスト計画IDを渡すとビルドの詳細情報を返す name:ビルド名 notes:ノート id:自ID is_open:オープンか? testplan_id:テスト計画ID active:アクティブか
getBuildsForTestPlan(tpid) #=>[{"name"=>"build1", "notes"=>"", "id"=>"1", "is_open"=>"1", "testplan_id"=>"3", "active"=>"1"}]
# File lib/TestLinkClient.rb, line 256
256: def getBuildsForTestPlan(tpid)
257: args = {"devKey"=>@devKey,"testplanid"=>tpid}
258: ret = @server.call("tl.getBuildsForTestPlan",args)
259: end
getProjectID
なし
最も大きい(最新の)IDでアクティブなテストプロジェクトID 例 3
最も大きい(最新の)IDでアクティブなテストプロジェクトIDが返ります
getProjectID #=>3
# File lib/TestLinkClient.rb, line 628
628: def getProjectID
629: args = {"devKey"=>@devKey}
630: ret = @server.call("tl.getProjects",args)
631: val = ret.select{|x|x["active"]=="1"}.sort{|a,b|a["id"].to_i<=>b["id"].to_i}
632: if not val.nil? then
633: return val[-1]["id"]
634: end
635: raise "ProjectID error"
636: end
getProjectTestPlans(pid)
| pid: | テストプロジェクトID |
例
[{"3"=>{"name"=>"test plan", "notes"=>"note", "id"=>"3", "testproject_id"=>"1", "active"=>"1"}}]
テストプロジェクトIDを渡すとテスト計画の詳細情報を返す - :テスト計画ID name:テスト計画名 notes:ノート id:自ID testproject_id:テストプロジェクトID active:アクティブか
getProjectTestPlans(pid) #=>[{"3"=>{"name"=>"test plan", "notes"=>"note", "id"=>"3", "testproject_id"=>"1", "active"=>"1"}}]
# File lib/TestLinkClient.rb, line 181
181: def getProjectTestPlans(pid)
182: args = {"devKey"=>@devKey,"testprojectid"=>pid}
183: ret = @server.call("tl.getProjectTestPlans",args)
184: end
getProjects
なし
現在のテストプロジェクト情報が返ります 例
[{"name"=>"project", "prefix"=>"test", "tc_counter"=>"15", "option_automation"=>"1", "option_priority"=>"1", "notes"=>"", "id"=>"1", "color"=>"", "option_reqs"=>"1", "active"=>"0"}, {"name"=>"testproject2", "prefix"=>"tp2", "tc_counter"=>"6", "option_automation"=>"1", "option_priority"=>"1", "notes"=>"<p>comment</p>","id"=>"35", "color"=>"", "option_reqs"=>"1", "active"=>"1"}]
プロジェクト毎に以下の値を得ることができます name:テストプロジェクト名 prefix:プレフィックス tc_counter:テストケース数 option_automation:automationを使用するか option_priority:優先度を使用するか notes:ノート id:テストプロジェクトID color: option_reqs:要件管理を使用するか active:アクティブプロジェクトか
getProjects #=>[{"name"=>"project", "prefix"=>"test", "tc_counter"=>"15", "option_automation"=>"1", "option_priority"=>"1", "notes"=>"", "id"=>"1", "color"=>"", "option_reqs"=>"1", "active"=>"0"}]
# File lib/TestLinkClient.rb, line 145
145: def getProjects
146: args = {"devKey"=>@devKey}
147: ret = @server.call("tl.getProjects",args)
148: end
getStatusByTCName(testcasename,testsuitename)
| testcasename: | テストケース名 |
| testsuitename: | テストスイート名 |
テスト結果 p:成功 f:失敗 b:ブロック を返す
テストケース名及びテストスイート名でテストケースの試験結果を得る
getStatusByTCName(testcasename,testsuitename,status) #=>"p"
# File lib/TestLinkClient.rb, line 771
771: def getStatusByTCName(testcasename,testsuitename)
772: pid = getProjectID
773: tpid = getTestPlanID(pid)
774: bid = getBuildID(tpid)
775: ret = getTestCaseIDByName(testcasename,testsuitename)
776: tcInfo = ret[0]
777: tcid = tcInfo["id"]
778: ret = getTestCasesForTestPlan(tpid,tcid)
779: ret.each{|key,val|
780: return val["exec_status"]
781: }
782: end
getTestCaseCustomFieldDesignValue()
カスタムフィールドの値を得る(使用方法不明)
getTestCaseCustomFieldDesignValue() #=>
# File lib/TestLinkClient.rb, line 507
507: def getTestCaseCustomFieldDesignValue()
508: args = {"devKey"=>@devKey}
509: ret = @server.call("tl.getTestCaseCustomFieldDesignValue",args)
510: end
getTestCaseIDByName(testcasename,testsuitename)
| testcasename: | テストケース名 |
| testsuitename: | テストスイート名(オプション) |
例
{"name"=>"testsuite1", "id"=>"36"}
テストケース名、テストスイート名を渡すとテストケースIDを返す name:テストケース名 id:テストケースID
getTestCaseIDByName(tsid) #=>[{"name"=>"testcase1", "id"=>"37"}]
# File lib/TestLinkClient.rb, line 433
433: def getTestCaseIDByName(testcasename,testsuitename = nil)
434: args = {"devKey"=>@devKey,"testcasename"=>testcasename}
435:
436: if testsuitename then
437: args["testsuitename"] = testsuitename
438: end
439:
440: ret = @server.call("tl.getTestCaseIDByName",args)
441: end
getTestCasesForTestPlan(tpid,tcid,bldid,keyid,execid,assignedto,executestatus)
tpid::テスト計画ID tcid::テストケースID(オプション) bldid::ビルドID(オプション) keyid::キーID(オプション) executed::(オプション) assignedto::(オプション) executestatus::(オプション)
例
{"45"=>{"exec_status"=>"n", "status"=>"", "name"=>"testcase1", "assigner_id"=>"", "urgency"=>"2", "exec_id"=>"", "type"=>"", "exec_on_tplan"=>"", "executed"=>"", "external_id"=>"4", "z"=>"100", "tc_id"=>"45", "version"=>"1", "tcversion_id"=>"46", "execution_order"=>"40", "user_id"=>"", "feature_id"=>"19", "tcversion_number"=>"", "testsuite_id"=>"44", "active"=>"1"}, "41"=>{"exec_status"=>"p", "status"=>"", "name"=>"testcase3", "assigner_id"=>"", "urgency"=>"2", "exec_id"=>"42", "type"=>"", "exec_on_tplan"=>"43", "executed"=>"42", "external_id"=>"3", "z"=>"100", "tc_id"=>"41", "version"=>"1", "tcversion_id"=>"42", "execution_order"=>"30", "user_id"=>"", "feature_id"=>"18", "tcversion_number"=>"1", "testsuite_id"=>"36", "active"=>"1"}}
テスト計画IDを渡すとテストケースの詳細情報を返す - :テストケースID exec_status:実行結果 p or f or b status: name:テストケース名 assigner_id: urgency: exec_id: type: exec_on_tplan: executed: external_id: z: tc_id:テストケースID version:テストケースバージョン tcversion_id:テストケースバージョンID execution_order: user_id: feature_id: tcversion_number: testsuite_id:テストスイートID active:アクティブか?
getTestCasesForTestPlan(tpid) #=>{"45"=>{"exec_status"=>"n", "status"=>"", "name"=>"testcase1", "assigner_id"=>"", "urgency"=>"2", "exec_id"=>"", "type"=>"", "exec_on_tplan"=>"", "executed"=>"", "external_id"=>"4", "z"=>"100", "tc_id"=>"45", "version"=>"1", "tcversion_id"=>"46", "execution_order"=>"40", "user_id"=>"", "feature_id"=>"19", "tcversion_number"=>"", "testsuite_id"=>"44", "active"=>"1"}, "41"=>{"exec_status"=>"p", "status"=>"", "name"=>"testcase3", "assigner_id"=>"", "urgency"=>"2", "exec_id"=>"42", "type"=>"", "exec_on_tplan"=>"43", "executed"=>"42", "external_id"=>"3", "z"=>"100", "tc_id"=>"41", "version"=>"1", "tcversion_id"=>"42", "execution_order"=>"30", "user_id"=>"", "feature_id"=>"18", "tcversion_number"=>"1", "testsuite_id"=>"36", "active"=>"1"}}
# File lib/TestLinkClient.rb, line 381
381: def getTestCasesForTestPlan(tpid,tcid=nil,bldid=nil,keyid=nil,executed=nil,assignedto=nil,executestatus=nil)
382: args = {"devKey"=>@devKey,"testplanid"=>tpid}
383: if tcid then
384: args["testcaseid"] = tcid
385: end
386: if bldid then
387: args["buildid"] = bldid
388: end
389: if keyid then
390: args["keywordid"] = keyid
391: end
392: if executed then #boolean
393: args["executed"] = executed
394: end
395: if assignedto then
396: args["assignedto"] = assignedto
397: end
398: if executestatus then #string
399: args["executestatus"] = executestatus
400: end
401: ret = @server.call("tl.getTestCasesForTestPlan",args)
402: end
getTestCasesForTestSuite(tsid)
| tsid: | テストスイートID |
| deep: | 再帰的検索を行う(オプション) デフォルトはTrue |
例
{"name"=>"testsuite1", "id"=>"36"}
テストスイートIDを渡すとテストケースの詳細情報を返す name:テストケース名 id:テストケースID node_type_id: parent_id: node_order:
getTestCasesForTestSuite(tsid) #=>{"name"=>"testsuite1", "id"=>"36"}
# File lib/TestLinkClient.rb, line 322
322: def getTestCasesForTestSuite(ts,deep=nil)
323: args = {"devKey"=>@devKey,"testsuiteid"=>ts}
324:
325: if deep then #
326: args["deep"] = deep
327: end
328:
329: ret = @server.call("tl.getTestCasesForTestSuite",args)
330: end
getTestPlanID(pid)
| pid: | テストプロジェクトID |
最も大きい(最新の)IDでアクティブなテスト計画ID 例 3
最も大きい(最新の)IDでアクティブなテスト計画IDが返ります
getTestPlanID(3) #=>4
# File lib/TestLinkClient.rb, line 660
660: def getTestPlanID(pid)
661: args = {"devKey"=>@devKey,"testprojectid"=>pid}
662: ret = @server.call("tl.getProjectTestPlans",args)
663: tpid=[]
664:
665: ret.each{|item|
666: item.each{|key,val|
667: tpid << key.to_i
668: }
669: }
670: tpid.sort
671: if tpid.size != 0 then
672: return tpid[-1]
673: end
674: raise "TestPlanID error"
675: end
getTestSuitesForTestPlan(tpid)
| tpid: | テスト計画ID |
例
{"name"=>"testsuite1", "id"=>"36"}
テスト計画IDを渡すとテストスイートの詳細情報を返す name:テストスイート名 id:自ID
getTestSuitesForTestPlan(tpid) #=>{"name"=>"testsuite1", "id"=>"36"}
# File lib/TestLinkClient.rb, line 287
287: def getTestSuitesForTestPlan(tpid)
288: args = {"devKey"=>@devKey,"testplanid"=>tpid}
289: ret = @server.call("tl.getTestSuitesForTestPlan",args)
290: end
repeat(message)
| message: | メッセージ |
"You said: xxxxx"
送信したメッセージを返す 動作確認用
repeat("message") #=>"You said: message"
You said: message
# File lib/TestLinkClient.rb, line 593
593: def repeat(message)
594: args = {"str"=>message}
595: ret = @server.call("tl.repeat",args)
596: end
reportTCResult(tpid,tcid,status,bid,notes,guess)
| tpid: | テスト計画ID |
| tcid: | テストケースID |
| status: | テスト結果 p:成功 f:失敗 b:ブロック |
| bid: | ビルドID(オプション) |
| notes: | ノート(オプション) |
| guess: | (オプション) |
例
[{"message"=>"Success!", "status"=>true, "id"=>"2"}]
テスト結果を登録する message:メッセージ id:ID status:true 成功 false 失敗
reportTCResult(tpid,bid,tcid,status) #=>[{"message"=>"Success!", "status"=>true, "id"=>"2"}]
# File lib/TestLinkClient.rb, line 96
96: def reportTCResult(tpid,tcid,status,bid=nil,notes=nil,guess=nil)
97:
98: args = {"devKey"=>@devKey,"testcaseid"=>tcid.to_i,"testplanid"=>tpid,"status"=>status,"buildid"=>bid}
99:
100: if bid then
101: args["buildid"] = bid
102: end
103: if notes then #string
104: args["notes"] = notes
105: end
106: if guess then #bool
107: args["guess"] = guess
108: end
109: ret = @server.call("tl.reportTCResult",args)
110: end
reportTCResultByTCName(testcasename,testsuitename,status,notes)
| testcasename: | テストケース名 |
| testsuitename: | テストスイート名 |
| status: | テスト結果 p:成功 f:失敗 b:ブロック |
| notes: | ノート(オプション) |
成功・失敗を返す
例 [{"message"=>"Success!", "status"=>true, "id"=>"1638"}]
テストケース名及びテストスイート名で指定したテストケースに試験結果を登録する
reportTCResultByTCName(testcasename,testsuitename,"p") #=>[{"message"=>"Success!", "status"=>true, "id"=>"1638"}]
# File lib/TestLinkClient.rb, line 737
737: def reportTCResultByTCName(testcasename,testsuitename,status,notes=nil)
738: pid = getProjectID
739: tpid = getTestPlanID(pid)
740: bid = getBuildID(tpid)
741: ret = getTestCaseIDByName(testcasename,testsuitename)
742: tcInfo = ret[0]
743: tcid = tcInfo["id"]
744: ret = reportTCResult(tpid,tcid,status,bid,notes)
745: end