Class: Testlink::Client::TestlinkAPIClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, key) ⇒ TestlinkAPIClient

Returns a new instance of TestlinkAPIClient.



15
16
17
18
# File 'lib/testlink/client.rb', line 15

def initialize uri, key
  @key = key
  @uri = get_api_uri uri
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



13
14
15
# File 'lib/testlink/client.rb', line 13

def key
  @key
end

#uriObject

Returns the value of attribute uri.



13
14
15
# File 'lib/testlink/client.rb', line 13

def uri
  @uri
end

Instance Method Details

#add_test_case_keywords(keywords) ⇒ Object



244
245
246
247
248
249
# File 'lib/testlink/client.rb', line 244

def add_test_case_keywords keywords

  # keywords is a map key: testcaseexternalid, values: array of keyword name
  input = { "keywords" => keywords }
  get_result "tl.addTestCaseKeywords", input
end

#check_dev_keyObject



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

def check_dev_key

  get_result "tl.checkDevKey"
end

#get_api_uri(uri) ⇒ Object



21
22
23
# File 'lib/testlink/client.rb', line 21

def get_api_uri uri
  uri + "/lib/api/xmlrpc/v1/xmlrpc.php"
end

#get_first_level_test_suites_for_test_project(tprojectid) ⇒ Object



172
173
174
175
176
# File 'lib/testlink/client.rb', line 172

def get_first_level_test_suites_for_test_project tprojectid

  input = {"testprojectid" => tprojectid }
  get_result "tl.getFirstLevelTestSuitesForTestProject", input
end

#get_last_execution_result_by_tcid(tplanid, tcid) ⇒ Object



57
58
59
60
61
62
# File 'lib/testlink/client.rb', line 57

def get_last_execution_result_by_tcid tplanid, tcid

  input = { "testplanid" => tplanid,
            "testcaseid" => tcid }
  get_result "tl.getLastExecutionResult", input
end

#get_latest_build_for_test_plan(tplanid) ⇒ Object



50
51
52
53
54
# File 'lib/testlink/client.rb', line 50

def get_latest_build_for_test_plan tplanid

  input = {"testplanid" => tplanid }
  get_result "tl.getLatestBuildForTestPlan", input
end

#get_project_keywords(tprojectid) ⇒ Object



78
79
80
81
82
# File 'lib/testlink/client.rb', line 78

def get_project_keywords tprojectid

  input = { "testprojectid" => tprojectid }
  get_result "tl.getProjectKeywords", input
end

#get_project_test_plans(tprojectid) ⇒ Object



71
72
73
74
75
# File 'lib/testlink/client.rb', line 71

def get_project_test_plans tprojectid

  input = { "testprojectid" => tprojectid }
  get_result "tl.getProjectTestPlans", input
end

#get_projectsObject



65
66
67
68
# File 'lib/testlink/client.rb', line 65

def get_projects
  
 get_result "tl.getProjects" 
end

#get_result(method, input = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/testlink/client.rb', line 26

def get_result method, input = {}
  connection = XMLRPC::Client.new_from_uri @uri
  input["devKey"] = @key

  result = connection.call2 method, input
  if result[0]
    if defined? result[1][0] and !result[1][0].nil? and result[1][0].has_key? "message"
      warn result[1][0]["message"]
      false
    else
      result[1]
    end
  else
    raise MethodCallFailed, "Method call to XMLRPC API failed."
  end
end

#get_test_case(tcid = nil, tcexternalid = nil) ⇒ Object



179
180
181
182
183
184
185
186
187
# File 'lib/testlink/client.rb', line 179

def get_test_case tcid = nil, tcexternalid = nil

  if tcexternalid.nil?
    input = { "testcaseid" => tcid }
  else
    input = { "testcaseexternalid" => tcexternalid }
  end
  get_result "tl.getTestCase", input
end

#get_test_case_by_tcexternalid(tcexternalid) ⇒ Object



196
197
198
199
# File 'lib/testlink/client.rb', line 196

def get_test_case_by_tcexternalid tcexternalid

  get_test_case nil, tcexternalid
end

#get_test_case_by_tcid(tcid) ⇒ Object



190
191
192
193
# File 'lib/testlink/client.rb', line 190

def get_test_case_by_tcid tcid

  get_test_case tcid
end

#get_test_case_id_by_name(tcasename, tsuitename = "", tprojectname = "", tcasepathname = "") ⇒ Object



162
163
164
165
166
167
168
169
# File 'lib/testlink/client.rb', line 162

def get_test_case_id_by_name tcasename, tsuitename = "", tprojectname = "", tcasepathname = ""

  input = { "testcasename" => tcasename,
            "testsuitename" => tsuitename,
            "testprojectname" => tprojectname,
            "testcasepathanme" => tcasepathname }
  get_result "tl.getTestCaseIDByName", input
end

#get_test_case_keywords(tcid = "", tcexternalid = "") ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'lib/testlink/client.rb', line 85

def get_test_case_keywords tcid = "", tcexternalid = ""

  if tcexternalid.nil?
    input = { "testcaseexternalid" => tcexternalid }
  else
    input = { "testcaseid" => tcid }
  end
  get_result "tl.getTestCaseKeywords", input
end

#get_test_case_keywords_by_tcexternalid(tcexternalid) ⇒ Object



101
102
103
# File 'lib/testlink/client.rb', line 101

def get_test_case_keywords_by_tcexternalid tcexternalid
  get_test_case_keywords "", tcexternalid
end

#get_test_case_keywords_by_tcid(tcid) ⇒ Object



96
97
98
# File 'lib/testlink/client.rb', line 96

def get_test_case_keywords_by_tcid tcid
  get_test_case_keywords tcid
end

#get_test_cases_for_test_plan(tplanid, buildid = nil, platformid = nil, testcaseid = nil, keywordid = nil, keywords = nil, executed = nil, assignedto = nil, executestatus = nil, executiontype = nil, getstepinfo = false, details = nil) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/testlink/client.rb', line 128

def get_test_cases_for_test_plan tplanid, buildid = nil, platformid = nil, testcaseid = nil, keywordid = nil, keywords = nil, executed = nil, assignedto = nil, executestatus = nil, executiontype = nil, getstepinfo = false, details = nil

  input = Hash.new
  input["testplanid"] = tplanid
  input["buildid"] = buildid unless buildid.nil?
  input["platformid"] = platformid unless platformid.nil?
  input["testcaseid"] = testcaseid unless testcaseid.nil?
  input["keywordid"] = keywordid unless keywordid.nil?
  input["keywords"] = keywords unless keywords.nil?
  input["executed"] = executed unless executed.nil?
  input["assignedto"] = assignedto unless assignedto.nil?
  input["executestatus"] = executestatus unless executestatus.nil?
  input["executiontype"] = executiontype unless executiontype.nil?
  input["getstepinfo"] = getstepinfo unless getstepinfo.nil?
  input["details"] = details unless details.nil?

  get_result "tl.getTestCasesForTestPlan", input
end

#get_test_cases_for_test_suite(tsuiteid, deep = true, details = "") ⇒ Object



147
148
149
150
151
152
153
# File 'lib/testlink/client.rb', line 147

def get_test_cases_for_test_suite tsuiteid, deep=true, details = ""

  input = { "testsuiteid" => tsuiteid, 
            "deep" => deep,
            "details" => details }
  get_result "tl.getTestCasesForTestSuite", input
end

#get_test_plan_by_name(tprojectname, tplanname) ⇒ Object



113
114
115
116
117
118
# File 'lib/testlink/client.rb', line 113

def get_test_plan_by_name tprojectname, tplanname

  input = { "testprojectname" => tprojectname,
            "testplanname" => tplanname }
  get_result "tl.getTestPlanByName", input
end

#get_test_project_by_name(tprojectname) ⇒ Object



106
107
108
109
110
# File 'lib/testlink/client.rb', line 106

def get_test_project_by_name tprojectname

  input = { "testprojectname" => tprojectname }
  get_result "tl.getTestProjectByName", input
end

#get_test_suite_by_id(tsuiteid) ⇒ Object



202
203
204
205
206
# File 'lib/testlink/client.rb', line 202

def get_test_suite_by_id tsuiteid

  input =  { "testsuiteid" => tsuiteid }
  get_result "tl.getTestSuiteByID", input
end

#get_test_suites_for_test_plan(tplanid) ⇒ Object



121
122
123
124
125
# File 'lib/testlink/client.rb', line 121

def get_test_suites_for_test_plan tplanid

  input = { "testplanid" => tplanid }
  get_result "tl.getTestSuitesForTestPlan", input
end

#get_test_suites_for_test_suite(tsuiteid) ⇒ Object



155
156
157
158
159
# File 'lib/testlink/client.rb', line 155

def get_test_suites_for_test_suite tsuiteid

  input = { "testsuiteid" => tsuiteid }
  get_result "tl.getTestSuitesForTestSuite", input
end

#get_user_by_id(userid) ⇒ Object



209
210
211
212
213
# File 'lib/testlink/client.rb', line 209

def get_user_by_id userid

  input =  { "userid" => userid }
  get_result "tl.getUserByID", input
end

#remove_test_case_keywords(keywords) ⇒ Object



252
253
254
255
256
# File 'lib/testlink/client.rb', line 252

def remove_test_case_keywords keywords

  input = { "keywords" => keywords }
  get_result "tl.removeTestCaseKeywords", input
end

#set_test_case_execution_type(tcid, version, tprojectid, executiontype) ⇒ Object



234
235
236
237
238
239
240
241
# File 'lib/testlink/client.rb', line 234

def set_test_case_execution_type tcid, version, tprojectid, executiontype

 input = { "testcaseid" => tcid,
           "version" => version,
           "testprojectid" => tprojectid,
           "executiontype" => executiontype }
get_result "tl.setTestCaseExecutionType", input 
end

#update_test_case(tcid, version = "", testcasename = "", summary = "", preconditions = "", steps = "", importance = "", executiontype = "", status = "", active = "", estimatedexecduration = "", user = "") ⇒ Object



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/testlink/client.rb', line 216

def update_test_case tcid, version = "", testcasename = "", summary = "", preconditions = "", steps = "", importance = "", executiontype = "", status = "", active = "", estimatedexecduration = "", user = ""

  input = { "testcaseid" => tcid,
            "version" => version,
            "testcasename" => testcasename,
            "summary" => summary,
            "preconditions" => preconditions,
            "steps" => steps,
            "importance" => importance,
            "executiontype" => executiontype,
            "status" => status,
            "active" => active,
            "estimatedexecduration" => estimatedexecduration,
            "user" => user }
  get_result "tl.updateTestCase", input
end