TestLinkClient 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/TestLinkClient.rb +308 -0
- metadata +53 -0
@@ -0,0 +1,308 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'xmlrpc/client'
|
3
|
+
# Author:: Sadahiko Hantani (garyohosu@gmail.com)
|
4
|
+
# Copyright:: Copyright (c) 2008 Sadahiko Hantani
|
5
|
+
# License:: Distributes under GPL
|
6
|
+
|
7
|
+
class TestLinkClient
|
8
|
+
#
|
9
|
+
#=== 概要
|
10
|
+
#
|
11
|
+
# initialize
|
12
|
+
#
|
13
|
+
#=== 引数
|
14
|
+
#
|
15
|
+
#+server_url+::
|
16
|
+
# TestLink Server URL
|
17
|
+
#+dev_key+::
|
18
|
+
# Personal API access key
|
19
|
+
#+api_path+::
|
20
|
+
# xmlrpc.php path (Option)
|
21
|
+
#
|
22
|
+
#=== 戻り値
|
23
|
+
#
|
24
|
+
# なし
|
25
|
+
#
|
26
|
+
#=== 例外
|
27
|
+
#
|
28
|
+
#=== 詳細
|
29
|
+
#
|
30
|
+
# TestLinkを設置したサーバーのURLとPersonal API access keyを設定します。
|
31
|
+
# Personal API access keyを入手するには以下を実行してください。
|
32
|
+
#
|
33
|
+
#1. TestLinkのconfig.inc.phpを変更します
|
34
|
+
# /** SOAP API availability (disabled by default) */
|
35
|
+
# $tlCfg->api_enabled = TRUE;
|
36
|
+
#2. user_api_keyを取得
|
37
|
+
# TestLinkを開き「Personal」を開く。
|
38
|
+
# 「Generate a new key」ボタンをクリック
|
39
|
+
# Personal API access key = xxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
40
|
+
#
|
41
|
+
#=== 例
|
42
|
+
# client = TestLinkClient.new("http://foo.org/testlink_18RC1","413a5f43341axxxxxx91f166501740ec")
|
43
|
+
#
|
44
|
+
def initialize(server_url,dev_key,api_path = "/lib/api/xmlrpc.php")
|
45
|
+
@server = XMLRPC::Client.new2(server_url + api_path)
|
46
|
+
@devKey = dev_key
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
#=== 概要
|
51
|
+
#
|
52
|
+
# getProjects
|
53
|
+
#
|
54
|
+
#=== 引数
|
55
|
+
#
|
56
|
+
# なし
|
57
|
+
#
|
58
|
+
#=== 戻り値
|
59
|
+
#
|
60
|
+
# 現在のテストプロジェクト情報が返ります
|
61
|
+
# 例
|
62
|
+
#[{"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"}]
|
63
|
+
#
|
64
|
+
#=== 詳細
|
65
|
+
#
|
66
|
+
# プロジェクト毎に以下の値を得ることができます
|
67
|
+
#
|
68
|
+
# name:テストプロジェクト名
|
69
|
+
# prefix:プレフィックス
|
70
|
+
# tc_counter:テストケース数
|
71
|
+
# option_automation:automationを使用するか
|
72
|
+
# option_priority:優先度を使用するか
|
73
|
+
# notes:ノート
|
74
|
+
# id:テストプロジェクトID
|
75
|
+
# color:
|
76
|
+
# option_reqs:要件管理を使用するか
|
77
|
+
# active:アクティブプロジェクトか
|
78
|
+
#
|
79
|
+
#=== 例
|
80
|
+
# getProjects #=>[{"name"=>"project", "prefix"=>"test", "tc_counter"=>"15", "option_automation"=>"1", "option_priority"=>"1", "notes"=>"", "id"=>"1", "color"=>"", "option_reqs"=>"1", "active"=>"0"}]
|
81
|
+
#
|
82
|
+
def getProjects
|
83
|
+
args = {"devKey"=>@devKey}
|
84
|
+
ret = @server.call("tl.getProjects",args)
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
#=== 概要
|
89
|
+
#
|
90
|
+
# getProjectTestPlans(pid)
|
91
|
+
#
|
92
|
+
#=== 引数
|
93
|
+
#
|
94
|
+
#+pid+::
|
95
|
+
# テストプロジェクトID
|
96
|
+
#
|
97
|
+
#=== 戻り値
|
98
|
+
# 例
|
99
|
+
# [{"3"=>{"name"=>"test plan", "notes"=>"note", "id"=>"3", "testproject_id"=>"1", "active"=>"1"}}]
|
100
|
+
#
|
101
|
+
#=== 例外
|
102
|
+
#
|
103
|
+
#=== 詳細
|
104
|
+
#
|
105
|
+
# テストプロジェクトIDを渡すとテスト計画の詳細情報を返す
|
106
|
+
#
|
107
|
+
# - :テスト計画ID
|
108
|
+
# name:テスト計画名
|
109
|
+
# notes:ノート
|
110
|
+
# id:自ID
|
111
|
+
# testproject_id:テストプロジェクトID
|
112
|
+
# active:アクティブか
|
113
|
+
#
|
114
|
+
#=== 例
|
115
|
+
#
|
116
|
+
# getProjectTestPlans(pid) #=>[{"3"=>{"name"=>"test plan", "notes"=>"note", "id"=>"3", "testproject_id"=>"1", "active"=>"1"}}]
|
117
|
+
#
|
118
|
+
def getProjectTestPlans(pid)
|
119
|
+
args = {"devKey"=>@devKey,"testprojectid"=>pid}
|
120
|
+
ret = @server.call("tl.getProjectTestPlans",args)
|
121
|
+
end
|
122
|
+
|
123
|
+
#
|
124
|
+
#=== 概要
|
125
|
+
#
|
126
|
+
# getBuildsForTestPlan(tpid)
|
127
|
+
#
|
128
|
+
#=== 引数
|
129
|
+
#
|
130
|
+
#+tpid+::
|
131
|
+
# テスト計画ID
|
132
|
+
#
|
133
|
+
#=== 戻り値
|
134
|
+
# 例
|
135
|
+
# [{"name"=>"build1", "notes"=>"", "id"=>"1", "is_open"=>"1", "testplan_id"=>"3", "active"=>"1"}]
|
136
|
+
#
|
137
|
+
#=== 例外
|
138
|
+
#
|
139
|
+
#=== 詳細
|
140
|
+
#
|
141
|
+
# テスト計画IDを渡すとビルドの詳細情報を返す
|
142
|
+
# name:ビルド名
|
143
|
+
# notes:ノート
|
144
|
+
# id:自ID
|
145
|
+
# is_open:オープンか?
|
146
|
+
# testplan_id:テスト計画ID
|
147
|
+
# active:アクティブか
|
148
|
+
#
|
149
|
+
#=== 例
|
150
|
+
#
|
151
|
+
# getBuildsForTestPlan(tpid) #=>[{"name"=>"build1", "notes"=>"", "id"=>"1", "is_open"=>"1", "testplan_id"=>"3", "active"=>"1"}]
|
152
|
+
#
|
153
|
+
def getBuildsForTestPlan(tpid)
|
154
|
+
args = {"devKey"=>@devKey,"testplanid"=>tpid}
|
155
|
+
ret = @server.call("tl.getBuildsForTestPlan",args)
|
156
|
+
end
|
157
|
+
|
158
|
+
#
|
159
|
+
#=== 概要
|
160
|
+
#
|
161
|
+
# getTestSuitesForTestPlan(tpid)
|
162
|
+
#
|
163
|
+
#=== 引数
|
164
|
+
#
|
165
|
+
#+tpid+::
|
166
|
+
# テスト計画ID
|
167
|
+
#
|
168
|
+
#=== 戻り値
|
169
|
+
# 例
|
170
|
+
# {"name"=>"testsuite1", "id"=>"36"}
|
171
|
+
#
|
172
|
+
#=== 例外
|
173
|
+
#
|
174
|
+
#=== 詳細
|
175
|
+
#
|
176
|
+
# テスト計画IDを渡すとテストスイートの詳細情報を返す
|
177
|
+
# name:テストスイート名
|
178
|
+
# id:自ID
|
179
|
+
#
|
180
|
+
#=== 例
|
181
|
+
#
|
182
|
+
# getTestSuitesForTestPlan(tpid) #=>{"name"=>"testsuite1", "id"=>"36"}
|
183
|
+
#
|
184
|
+
def getTestSuitesForTestPlan(tpid)
|
185
|
+
args = {"devKey"=>@devKey,"testplanid"=>tpid}
|
186
|
+
ret = @server.call("tl.getTestSuitesForTestPlan",args)
|
187
|
+
end
|
188
|
+
#
|
189
|
+
#=== 概要
|
190
|
+
#
|
191
|
+
# getTestSuitesForTestPlan(tpid)
|
192
|
+
#
|
193
|
+
#=== 引数
|
194
|
+
#
|
195
|
+
#+tpid+::
|
196
|
+
# テスト計画ID
|
197
|
+
#
|
198
|
+
#=== 戻り値
|
199
|
+
# 例
|
200
|
+
# {"name"=>"testsuite1", "id"=>"36"}
|
201
|
+
#
|
202
|
+
#=== 例外
|
203
|
+
#
|
204
|
+
#=== 詳細
|
205
|
+
#
|
206
|
+
# テスト計画IDを渡すとテストスイートの詳細情報を返す
|
207
|
+
# name:テストスイート名
|
208
|
+
# id:自ID
|
209
|
+
#
|
210
|
+
#=== 例
|
211
|
+
#
|
212
|
+
# getTestSuitesForTestPlan(tpid) #=>{"name"=>"testsuite1", "id"=>"36"}
|
213
|
+
#
|
214
|
+
def getTestCasesForTestSuite(ts)
|
215
|
+
args = {"devKey"=>@devKey,"testsuiteid"=>ts}
|
216
|
+
ret = @server.call("tl.getTestCasesForTestSuite",args)
|
217
|
+
end
|
218
|
+
|
219
|
+
def getTestCasesForTestPlan(tpid)
|
220
|
+
args = {"devKey"=>@devKey,"testplanid"=>tpid}
|
221
|
+
ret = @server.call("tl.getTestCasesForTestPlan",args)
|
222
|
+
end
|
223
|
+
|
224
|
+
def getTestCaseIDByName(testcasename,testsuitename = nil)
|
225
|
+
args = {"devKey"=>@devKey,"testcasename"=>testcasename}
|
226
|
+
|
227
|
+
if testsuitename then
|
228
|
+
args["testsuitename"] = testsuitename
|
229
|
+
end
|
230
|
+
|
231
|
+
ret = @server.call("tl.getTestCaseIDByName",args)
|
232
|
+
end
|
233
|
+
|
234
|
+
def reportTCResult(tpid,bid,tcid,status)
|
235
|
+
args = {"devKey"=>@devKey,"testcaseid"=>tcid.to_i,"testplanid"=>tpid,"status"=>status,"buildid"=>bid}
|
236
|
+
ret = @server.call("tl.reportTCResult",args)
|
237
|
+
end
|
238
|
+
|
239
|
+
#Hello!
|
240
|
+
def sayHello
|
241
|
+
ret = @server.call("tl.sayHello")
|
242
|
+
end
|
243
|
+
|
244
|
+
#You said: message
|
245
|
+
def repeat(message)
|
246
|
+
args = {"str"=>message}
|
247
|
+
ret = @server.call("tl.repeat",args)
|
248
|
+
end
|
249
|
+
|
250
|
+
# Testlink API Version: 1.0 Beta 3 written by Asiel Brumfield
|
251
|
+
# contribution by TestLink development Team
|
252
|
+
def about
|
253
|
+
ret = @server.call("tl.about")
|
254
|
+
end
|
255
|
+
|
256
|
+
######################################
|
257
|
+
|
258
|
+
def getProjectID
|
259
|
+
args = {"devKey"=>@devKey}
|
260
|
+
ret = @server.call("tl.getProjects",args)
|
261
|
+
ret.each{|prj|
|
262
|
+
if prj["active"] == "1" then
|
263
|
+
return prj["id"]
|
264
|
+
end
|
265
|
+
}
|
266
|
+
raise "ProjectID error"
|
267
|
+
end
|
268
|
+
|
269
|
+
def getTestPlanID(pid)
|
270
|
+
args = {"devKey"=>@devKey,"testprojectid"=>pid}
|
271
|
+
ret = @server.call("tl.getProjectTestPlans",args)
|
272
|
+
ret.each{|tp|
|
273
|
+
tp.each{|id,val|
|
274
|
+
if val["active"] == "1" then
|
275
|
+
return val["id"]
|
276
|
+
end
|
277
|
+
}
|
278
|
+
}
|
279
|
+
raise "TestPlanID error"
|
280
|
+
end
|
281
|
+
|
282
|
+
def getBuildID(tpid)
|
283
|
+
args = {"devKey"=>@devKey,"testplanid"=>tpid}
|
284
|
+
ret = @server.call("tl.getBuildsForTestPlan",args)
|
285
|
+
ret.each{|val|
|
286
|
+
if val["active"] == "1" then
|
287
|
+
return val["id"]
|
288
|
+
end
|
289
|
+
}
|
290
|
+
raise "BuildID error"
|
291
|
+
end
|
292
|
+
|
293
|
+
def getTestSuiteID(tpid)
|
294
|
+
args = {"devKey"=>@devKey,"testplanid"=>tpid}
|
295
|
+
ret = @server.call("tl.getTestSuitesForTestPlan",args)
|
296
|
+
end
|
297
|
+
|
298
|
+
def reportTCResultByTCName(testcasename,testsuitename,status)
|
299
|
+
pid = getProjectID
|
300
|
+
tpid = getTestPlanID(pid)
|
301
|
+
bid = getBuildID(tpid)
|
302
|
+
ret = getTestCaseIDByName(testcasename,testsuitename)
|
303
|
+
tcInfo = ret[0]
|
304
|
+
tcid = tcInfo["id"]
|
305
|
+
ret = reportTCResult(tpid,bid,tcid,status)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: TestLinkClient
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SADAHIKO Hantani
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-12 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: garyohosu@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/TestLinkClient.rb
|
26
|
+
has_rdoc: false
|
27
|
+
homepage: http://ruby.g.hatena.ne.jp/garyo/
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: "0"
|
38
|
+
version:
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
requirements: []
|
46
|
+
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 0.9.5
|
49
|
+
signing_key:
|
50
|
+
specification_version: 2
|
51
|
+
summary: TestLink XMLRPC Client
|
52
|
+
test_files: []
|
53
|
+
|