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_testcase_keywords(keywords) ⇒ Object



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

def add_testcase_keywords keywords

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

#check_dev_key(dev_key) ⇒ Object



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

def check_dev_key dev_key

  get_result "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



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

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



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

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



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

def get_latest_build_for_test_plan tplanid

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

#get_project_keywords(tprojectid) ⇒ Object



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

def get_project_keywords tprojectid

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

#get_project_test_plans(tprojectid) ⇒ Object



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

def get_project_test_plans tprojectid

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

#get_projectsObject



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

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
# 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 result[1][0].class == {}.class and result[1][0].has_key? "message"
      warn result[1][0]["message"]
    else
      result[1]
    end
  else
    raise MethodCallFailed, "Method call to XMLRPC API failed."
  end
end

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



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

def get_test_case tcid = nil, tcexternalid = nil

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

#get_test_case_by_tcexternalid(tcexternalid) ⇒ Object



186
187
188
189
# File 'lib/testlink/client.rb', line 186

def get_test_case_by_tcexternalid tcexternalid

  get_test_case nil, tcexternalid
end

#get_test_case_by_tcid(tcid) ⇒ Object



180
181
182
183
# File 'lib/testlink/client.rb', line 180

def get_test_case_by_tcid tcid

  get_test_case tcid
end

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



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

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

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

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



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

def get_test_case_keywords tcid = nil, tcexternalid = nil

  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



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

def get_test_case_keywords_by_tcexternalid tcexternalid
  get_test_case_keywords nil, tcexternalid
end

#get_test_case_keywords_by_tcid(tcid) ⇒ Object



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

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



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

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 = { "testplanid" => tplanid, 
            "buildid" => buildid,
            "platformid" => platformid,
            "testcaseid" => testcaseid,
            "keywordid" => keywordid,
            "keywords" => keywords,
            "executed" => executed,
            "assignedto" => assignedto,
            "executestatus" => executestatus,
            "executiontype" => executiontype,
            "getstepinfo" => getstepinfo,
            "details" => details }
  get_result "tl.getTestCasesForTestPlan", input
end

#get_test_plan_by_name(tprojectname, tplanname) ⇒ Object



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

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



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

def get_test_project_by_name tprojectname

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

#get_test_suite_by_id(tsuiteid) ⇒ Object



192
193
194
195
196
# File 'lib/testlink/client.rb', line 192

def get_test_suite_by_id tsuiteid

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

#get_test_suites_for_test_plan(tplanid) ⇒ Object



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

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



145
146
147
148
149
# File 'lib/testlink/client.rb', line 145

def get_test_suites_for_test_suite tsuiteid

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

#get_user_by_id(userid) ⇒ Object



199
200
201
202
203
# File 'lib/testlink/client.rb', line 199

def get_user_by_id userid

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

#remove_test_case_keywords(keywords) ⇒ Object



241
242
243
244
245
# File 'lib/testlink/client.rb', line 241

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



223
224
225
226
227
228
229
230
# File 'lib/testlink/client.rb', line 223

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 = nil, testcasename = nil, summary = nil, preconditions = nil, steps = nil, importance = nil, executiontype = nil. status = nil, estimatedexecduration = nil, user = nil) ⇒ Object



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/testlink/client.rb', line 206

def update_test_case tcid, version = nil, testcasename = nil, summary = nil, preconditions = nil, steps = nil, importance = nil, executiontype = nil. status = nil, estimatedexecduration = nil, user = nil

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