Class: TestLinkClient

Inherits:
Object
  • Object
show all
Defined in:
lib/TestLinkClient.rb

Overview

License

Distributes under GPL

Instance Method Summary collapse

Constructor Details

#initialize(server_url, dev_key, api_path = "/lib/api/xmlrpc.php") ⇒ TestLinkClient



44
45
46
47
# File 'lib/TestLinkClient.rb', line 44

def initialize(server_url,dev_key,api_path = "/lib/api/xmlrpc.php")
  @server = XMLRPC::Client.new2(server_url + api_path)
  @devKey = dev_key
end

Instance Method Details

#aboutObject

Testlink API Version: 1.0 Beta 3 written by Asiel Brumfield contribution by TestLink development Team



252
253
254
# File 'lib/TestLinkClient.rb', line 252

def about
  ret = @server.call("tl.about")
end

#getBuildID(tpid) ⇒ Object



282
283
284
285
286
287
288
289
290
291
# File 'lib/TestLinkClient.rb', line 282

def getBuildID(tpid)
  args = {"devKey"=>@devKey,"testplanid"=>tpid}     
  ret = @server.call("tl.getBuildsForTestPlan",args)
  ret.each{|val|
    if val["active"] == "1" then
      return val["id"]
    end
  }
  raise "BuildID error"
end

#getBuildsForTestPlan(tpid) ⇒ Object

概要

getBuildsForTestPlan(tpid)

引数

tpid

テスト計画ID

戻り値

例 ["notes"=>"", "id"=>"1", "is_open"=>"1", "testplan_id"=>"3", "active"=>"1"]

例外

詳細

テスト計画IDを渡すとビルドの詳細情報を返す name:ビルド名 notes:ノート id:自ID is_open:オープンか? testplan_id:テスト計画ID active:アクティブか

getBuildsForTestPlan(tpid) #=>["notes"=>"", "id"=>"1", "is_open"=>"1", "testplan_id"=>"3", "active"=>"1"]



153
154
155
156
# File 'lib/TestLinkClient.rb', line 153

def getBuildsForTestPlan(tpid)
  args = {"devKey"=>@devKey,"testplanid"=>tpid}     
  ret = @server.call("tl.getBuildsForTestPlan",args)
end

#getProjectIDObject



258
259
260
261
262
263
264
265
266
267
# File 'lib/TestLinkClient.rb', line 258

def getProjectID
  args = {"devKey"=>@devKey}
  ret = @server.call("tl.getProjects",args)
  ret.each{|prj|
    if prj["active"] == "1" then
       return prj["id"]
    end
  }
  raise "ProjectID error"
end

#getProjectsObject

概要

getProjects

引数

なし

戻り値

現在のテストプロジェクト情報が返ります 例 ["prefix"=>"test", "tc_counter"=>"15", "option_automation"=>"1", "option_priority"=>"1", "notes"=>"", "id"=>"1", "color"=>"", "option_reqs"=>"1", "active"=>"0", "prefix"=>"tp2", "tc_counter"=>"6", "option_automation"=>"1", "option_priority"=>"1", "notes"=>"

comment

","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 #=>["prefix"=>"test", "tc_counter"=>"15", "option_automation"=>"1", "option_priority"=>"1", "notes"=>"", "id"=>"1", "color"=>"", "option_reqs"=>"1", "active"=>"0"]



82
83
84
85
# File 'lib/TestLinkClient.rb', line 82

def getProjects
  args = {"devKey"=>@devKey}
  ret = @server.call("tl.getProjects",args)
end

#getProjectTestPlans(pid) ⇒ Object

概要

getProjectTestPlans(pid)

引数

pid

テストプロジェクトID

戻り値

例 [plan", "notes"=>"note", "id"=>"3", "testproject_id"=>"1", "active"=>"1"}]

例外

詳細

テストプロジェクトIDを渡すとテスト計画の詳細情報を返す

  • :テスト計画ID name:テスト計画名 notes:ノート id:自ID testproject_id:テストプロジェクトID active:アクティブか

getProjectTestPlans(pid) #=>[plan", "notes"=>"note", "id"=>"3", "testproject_id"=>"1", "active"=>"1"}]



118
119
120
121
# File 'lib/TestLinkClient.rb', line 118

def getProjectTestPlans(pid)
  args = {"devKey"=>@devKey,"testprojectid"=>pid}     
  ret = @server.call("tl.getProjectTestPlans",args)
end

#getTestCaseIDByName(testcasename, testsuitename = nil) ⇒ Object



224
225
226
227
228
229
230
231
232
# File 'lib/TestLinkClient.rb', line 224

def getTestCaseIDByName(testcasename,testsuitename = nil)
  args = {"devKey"=>@devKey,"testcasename"=>testcasename}

  if testsuitename then
   args["testsuitename"] = testsuitename
  end

  ret = @server.call("tl.getTestCaseIDByName",args)
end

#getTestCasesForTestPlan(tpid) ⇒ Object



219
220
221
222
# File 'lib/TestLinkClient.rb', line 219

def getTestCasesForTestPlan(tpid)
  args = {"devKey"=>@devKey,"testplanid"=>tpid}     
  ret = @server.call("tl.getTestCasesForTestPlan",args)
end

#getTestCasesForTestSuite(ts) ⇒ Object

getTestSuitesForTestPlan(tpid) #=>"id"=>"36"



214
215
216
217
# File 'lib/TestLinkClient.rb', line 214

def getTestCasesForTestSuite(ts)
  args = {"devKey"=>@devKey,"testsuiteid"=>ts}     
  ret = @server.call("tl.getTestCasesForTestSuite",args)
end

#getTestPlanID(pid) ⇒ Object



269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/TestLinkClient.rb', line 269

def getTestPlanID(pid)
  args = {"devKey"=>@devKey,"testprojectid"=>pid}     
  ret = @server.call("tl.getProjectTestPlans",args)
  ret.each{|tp|
    tp.each{|id,val|
      if val["active"] == "1" then
        return val["id"]
      end
    }
  }
  raise "TestPlanID error"
end

#getTestSuiteID(tpid) ⇒ Object



293
294
295
296
# File 'lib/TestLinkClient.rb', line 293

def getTestSuiteID(tpid)
  args = {"devKey"=>@devKey,"testplanid"=>tpid}     
  ret = @server.call("tl.getTestSuitesForTestPlan",args)
end

#getTestSuitesForTestPlan(tpid) ⇒ Object

概要

getTestSuitesForTestPlan(tpid)

引数

tpid

テスト計画ID

戻り値

例 "id"=>"36"

例外

詳細

テスト計画IDを渡すとテストスイートの詳細情報を返す name:テストスイート名 id:自ID

getTestSuitesForTestPlan(tpid) #=>"id"=>"36"



184
185
186
187
# File 'lib/TestLinkClient.rb', line 184

def getTestSuitesForTestPlan(tpid)
  args = {"devKey"=>@devKey,"testplanid"=>tpid}     
  ret = @server.call("tl.getTestSuitesForTestPlan",args)
end

#repeat(message) ⇒ Object

You said: message



245
246
247
248
# File 'lib/TestLinkClient.rb', line 245

def repeat(message)
  args = {"str"=>message}
  ret = @server.call("tl.repeat",args)
end

#reportTCResult(tpid, bid, tcid, status) ⇒ Object



234
235
236
237
# File 'lib/TestLinkClient.rb', line 234

def reportTCResult(tpid,bid,tcid,status)
  args = {"devKey"=>@devKey,"testcaseid"=>tcid.to_i,"testplanid"=>tpid,"status"=>status,"buildid"=>bid}
  ret = @server.call("tl.reportTCResult",args)
end

#reportTCResultByTCName(testcasename, testsuitename, status) ⇒ Object



298
299
300
301
302
303
304
305
306
# File 'lib/TestLinkClient.rb', line 298

def reportTCResultByTCName(testcasename,testsuitename,status)
  pid = getProjectID
  tpid = getTestPlanID(pid)
  bid = getBuildID(tpid)
  ret = getTestCaseIDByName(testcasename,testsuitename)
  tcInfo = ret[0]
  tcid = tcInfo["id"]
  ret = reportTCResult(tpid,bid,tcid,status)
end

#sayHelloObject

Hello!



240
241
242
# File 'lib/TestLinkClient.rb', line 240

def sayHello
  ret = @server.call("tl.sayHello")
end