test_linker 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -2,3 +2,7 @@
2
2
  --title "test_linker Documentation"
3
3
  --protected
4
4
  --private
5
+ -
6
+ ChangeLog.rdoc
7
+ LICENSE.rdoc
8
+ README.rdoc
@@ -1,3 +1,18 @@
1
+ === 1.0.1 / 2011-06-19
2
+
3
+ * Fixed bugs:
4
+ * #1: Gemspec showed duplicate dependencies. Switched to .gemspec and `gem build`
5
+ for building the gem (no more jeweler).
6
+ * #3: #test_case_execution_result= now uses #make_call. (thanks fishstick!)
7
+ * #4: #find_test_plans now works with TestLink 1.9.x. (thanks fishstick!)
8
+ * #5: #test_case_execution_result= now uses @dev_key (via #make_call). This
9
+ is really the same fix as for #3. (thanks fishstick!)
10
+ * #9: Added .rdoc files to .yardopts in hopes that rdoc.info will use that to
11
+ add the ChangeLog and LICENSE files to the Files list.
12
+ * Fixed author in gemspec.
13
+ * Improvements:
14
+ * Started using log_switch for class logging.
15
+
1
16
  === 1.0.0 / 2011-05-08
2
17
 
3
18
  * Added support for new (old) Rubies:
data/Gemfile CHANGED
@@ -1,14 +1,3 @@
1
1
  source :rubygems
2
+ gemspec
2
3
 
3
- #gemspec
4
- gem 'versionomy', '~> 0.4.0'
5
-
6
- group :development do
7
- gem 'bundler', '~> 1.0.0'
8
- gem 'cucumber', '~> 0.10.0'
9
- gem 'fakeweb', '~> 1.3.0'
10
- gem 'jeweler', '~> 1.6.0'
11
- gem 'rspec', '~> 2.5'
12
- gem 'simplecov', '>= 0.4.0', :require => false if RUBY_VERSION >= "1.9"
13
- gem 'yard', '~> 0.6.0'
14
- end
@@ -6,6 +6,7 @@
6
6
 
7
7
  == Description
8
8
 
9
+
9
10
  This is a Ruby wrapper around the TestLink XMLRPC API, thus allowing access to
10
11
  your TestLink test projects, plans, cases, and results using Ruby. We've added
11
12
  a few helper methods as well to allow for getting at more of your data a little
@@ -106,9 +107,8 @@ Get results to a CSV file:
106
107
  * bundler, ~> 1.0.0
107
108
  * cucumber, ~> 0.10.0
108
109
  * fakeweb, ~> 1.3.0
109
- * jeweler, ~> 1.5.0
110
110
  * rspec, ~> 2.5.0
111
- * simplecov, >= 0.4.0
111
+ * simplecov, >= 0.4.0 (MRI 1.9.x only)
112
112
  * yard, ~> 0.6.0
113
113
 
114
114
  Getting it all running (on the TestLink side):
data/Rakefile CHANGED
@@ -1,51 +1,14 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
-
4
- begin
5
- Bundler.setup(:default, :development)
6
- rescue Bundler::BundlerError => e
7
- $stderr.puts e.message
8
- $stderr.puts "Run `bundle install` to install missing gems"
9
- exit e.status_code
10
- end
11
-
12
- require 'rake'
13
-
14
- $:.unshift Dir.pwd + "/lib"
15
- require 'test_linker'
16
- require 'jeweler'
17
- Jeweler::Tasks.new do |gem|
18
- gem.name = "test_linker"
19
- gem.version = TestLinker::VERSION
20
- gem.homepage = "http://github.com/turboladen/test_linker"
21
- gem.license = "MIT"
22
- gem.summary = %Q{An interface to the TestLink XMLRPC API}
23
- gem.description = %Q{This is a Ruby wrapper around the TestLink XMLRPC API, thus allowing access to
24
- your TestLink test projects, plans, cases, and results using Ruby. We've added
25
- a few helper methods as well to allow for getting at more of your data a little
26
- easier. This supports TestLink APIs 1.0 Beta 5 (from TestLink 1.8.x) and 1.0
27
- (from TestLink 1.9.x)..}
28
- gem.email = "steve.loveless@gmail.com"
29
- gem.authors = ["turboladen"]
30
- gem.add_bundler_dependencies
31
- end
32
- Jeweler::RubygemsDotOrgTasks.new
33
-
34
- require 'rspec/core'
3
+ require 'bundler/gem_tasks'
4
+ require 'cucumber/rake/task'
35
5
  require 'rspec/core/rake_task'
6
+ require 'yard'
7
+
36
8
  RSpec::Core::RakeTask.new(:spec) do |spec|
37
9
  spec.pattern = FileList['spec/**/*_spec.rb']
38
10
  end
11
+ task :test => :spec
39
12
 
40
- RSpec::Core::RakeTask.new(:rcov) do |spec|
41
- spec.pattern = 'spec/**/*_spec.rb'
42
- spec.rcov = true
43
- end
44
-
45
- require 'cucumber/rake/task'
46
13
  Cucumber::Rake::Task.new(:features)
47
-
48
- task :default => :spec
49
-
50
- require 'yard'
51
14
  YARD::Rake::YardocTask.new
@@ -1,6 +1,7 @@
1
1
  require 'logger'
2
2
  require 'rubygems'
3
3
  require 'versionomy'
4
+ require 'log_switch'
4
5
 
5
6
  require File.expand_path(File.dirname(__FILE__) + '/core_ext/hash_patch')
6
7
  require File.expand_path(File.dirname(__FILE__) + '/test_linker/wrapper')
@@ -10,51 +11,12 @@ require File.expand_path(File.dirname(__FILE__) + '/test_linker/helpers')
10
11
  require File.expand_path(File.dirname(__FILE__) + '/core_ext/xmlrpc_client_patch')
11
12
 
12
13
  class TestLinker
14
+ extend LogSwitch
13
15
  include TestLinker::Wrapper
14
16
  include TestLinker::Helpers
15
17
 
16
- class << self
17
-
18
- # @return [Boolean] Returns if logging is enabled or not.
19
- def log?
20
- @log ||= false
21
- end
22
-
23
- # @param [Boolean] do_logging false to turn logging off; true to turn it
24
- # back on.
25
- def log=(do_logging)
26
- @log = do_logging
27
- end
28
-
29
- # @return [Logger,?] Returns a Logger unless you use a different type of
30
- # logging object.
31
- def logger
32
- @logger ||= Logger.new STDOUT
33
- end
34
-
35
- # @param [?] logging_object Call this to use a different type of logger
36
- # than Logger.
37
- def logger=(logging_object)
38
- @logger = logging_object
39
- end
40
-
41
- # @return [Symbol] The method name to send to the logging object in order to
42
- # log messages.
43
- def log_level
44
- @log_level ||= :debug
45
- end
46
-
47
- # @param [Symbol] The method name to send to the logging object in order to
48
- # log messages.
49
- def log_level=(level)
50
- @log_level = level
51
- end
52
-
53
- # @param [String] message The string to log.
54
- def log message
55
- logger.send(log_level, message) if log?
56
- end
57
- end
18
+ # Turn logging off by default.
19
+ self.log = false
58
20
 
59
21
  # Default value for timing out after not receiving an XMLRPC response from
60
22
  # the server.
@@ -32,7 +32,7 @@ module TestLinker::Helpers
32
32
  #
33
33
  # @param [String] project_name Name of the project to search for.
34
34
  # @param [String] plan_name Name of the plan to search for.
35
- # @return [Fixnum] ID of plan matching project_name and plan_name. 0 if the
35
+ # @return [Fixnum] ID of plan matching project_name and plan_name. nil if the
36
36
  # test plan wasn't found.
37
37
  def test_plan_id(project_name, plan_name)
38
38
  if @version < "1.0"
@@ -54,7 +54,7 @@ module TestLinker::Helpers
54
54
  # @param [String] project_name Name of the project to search for.
55
55
  # @param [String] plan_name Name of the plan to search for.
56
56
  # @param [String] build_name Name of the build to search for.
57
- # @return [Fixnum] ID of plan matching project_name and plan_name
57
+ # @return [Fixnum] ID of plan matching project_name and plan_name.
58
58
  def build_id(project_name, plan_name, build_name)
59
59
  plan_id = test_plan_id(project_name, plan_name)
60
60
  builds = builds_for_test_plan plan_id
@@ -89,12 +89,21 @@ module TestLinker::Helpers
89
89
  # @return [Array] An array of test plans that match the Regexp.
90
90
  def find_test_plans(project_id, regex, match_attribute=:name)
91
91
  test_plan_list = test_plans(project_id)
92
+ matched_list = []
92
93
 
93
- test_plan_list.first.values.find_all do |project_test_plan|
94
- project_test_plan[match_attribute] =~ regex
94
+ if @version >= "1.0"
95
+ matched_list = test_plan_list.find_all do |plan|
96
+ plan[match_attribute] =~ regex
97
+ end
98
+ elsif @version < "1.0"
99
+ test_plan_list.first.each_value do |plan|
100
+ matched_list << plan if plan[match_attribute] =~ regex
101
+ end
95
102
  end
103
+
104
+ matched_list
96
105
  end
97
-
106
+
98
107
  # @param [String] project_name
99
108
  # @param [String] suite_name
100
109
  # @return [Fixnum] ID of the requested test suite. nil if not found.
@@ -149,6 +158,7 @@ module TestLinker::Helpers
149
158
  # @param [String] project_name
150
159
  # @param [String] suite_name
151
160
  # @return [String] ID of the created or existing suite.
161
+ # TODO: This should rescue TestLinker::Error
152
162
  def create_first_level_suite(project_name, suite_name)
153
163
  return first_level_test_suite_id(project_name, suite_name)
154
164
  rescue RuntimeError
@@ -159,6 +169,100 @@ module TestLinker::Helpers
159
169
  create_test_suite(project_id, suite_name).first[:id]
160
170
  end
161
171
 
172
+ # Checks if the test case has been executed.
173
+ #
174
+ # Todo:
175
+ # * versioning support (make_call = :exec_status vs 'exec_status')'
176
+ # * Also accept TC_ID instead?
177
+ # @param [Hash] test_case A testcase Hash (AKA 'testcase info')
178
+ # @return [Boolean] true if the test hasn't yet been executed.
179
+ def test_not_run?(test_case)
180
+ test_case[:exec_status] == 'n'
181
+ end
182
+
183
+ # Returns all open (not-run) test cases for a given plan within project.
184
+ # Extra options for now are +:build+, which will match a given build rather
185
+ # than all open builds by default.
186
+ #
187
+ # @param [String] project_name
188
+ # @param [String] plan_name
189
+ # @param [Hash] options
190
+ # @option options [String] build Name of the build to match.
191
+ # @return [Array<Hash>] Array of matching testcase hashes.
192
+ # @see #find_open_cases_for_plans
193
+ def find_open_cases_for_plan(project_name, plan_name, options={})
194
+ test_case_array = []
195
+ plan_id = test_plan_id(project_name, plan_name)
196
+
197
+ if plan_id.nil?
198
+ return []
199
+ else
200
+ builds = builds_for_test_plan(plan_id)
201
+ end
202
+
203
+ builds.each do |build|
204
+ if options[:build]
205
+ if build[:name] =~ options[:build]
206
+ test_cases = test_cases_for_test_plan(build[:testplan_id],
207
+ { "buildid" => build[:id] })
208
+ end
209
+ elsif build[:is_open] == 1
210
+ test_cases = test_cases_for_test_plan(build[:testplan_id],
211
+ { "buildid" => build[:id] })
212
+ end
213
+
214
+ unless test_cases.nil?
215
+ test_cases.each_value do |test_case|
216
+ test_case_array << test_case if test_not_run?(test_case)
217
+ end
218
+ end
219
+ end
220
+
221
+ test_case_array
222
+ end
223
+
224
+ # Returns all open (not-run) test cases for a set of test plans within project
225
+ # that match the given Regexp. Extra options for now are +:build+, which will
226
+ # match a given build rather than all open builds by default.
227
+ #
228
+ # @param [String] project_name
229
+ # @param [Regexp] plan_regex Plan name as regex.
230
+ # @param [Hash] options
231
+ # @option options [String] build Name of the build to match.
232
+ # @return [Array<Hash>] Array of matching testcase hashes.
233
+ def find_open_cases_for_plans(project_name, plan_regex, options={})
234
+ puts 'meow'
235
+ test_case_array = []
236
+ project_id = project_id(project_name)
237
+ puts "project ID: #{project_id}"
238
+ test_plans = find_test_plans(project_id, plan_regex)
239
+ puts "test plans: #{test_plans}"
240
+
241
+ test_plans.each do |test_plan|
242
+ builds = builds_for_test_plan(test_plan[:id]) # Get builds for plan(s)
243
+
244
+ builds.each do |build|
245
+ if options[:build]
246
+ if build[:name] =~ options[:build]
247
+ test_cases = test_cases_for_test_plan(build[:testplan_id],
248
+ { "buildid" => build[:id] })
249
+ end
250
+ elsif build[:is_open] == 1
251
+ test_cases = test_cases_for_test_plan(build[:testplan_id],
252
+ { "buildid" => build[:id] })
253
+ end
254
+
255
+ unless test_cases.nil?
256
+ test_cases.each_value do |test_case|
257
+ test_case_array << test_case if test_not_run?(test_case)
258
+ end
259
+ end
260
+ end
261
+ end
262
+
263
+ test_case_array
264
+ end
265
+ alias_method :find_open_cases_for_plans, :find_open_cases_for_plan
162
266
  # Get the ID of a suite with the given parent, creating it if it does not
163
267
  # exist.
164
268
  #
@@ -203,7 +307,7 @@ module TestLinker::Helpers
203
307
  test_suite_id = self.suite_info(project_name, plan_name, suite_name)
204
308
 
205
309
  result = create_test_case(test_project_id, test_suite_id, test_case_name,
206
- summary, steps, expected_results, login)
310
+ summary, steps, expected_results, login)
207
311
 
208
312
  if result.any?
209
313
  result.each do |result_ptr|
@@ -235,7 +339,7 @@ module TestLinker::Helpers
235
339
  def add_test_case_to_test_plan_by_name(project_name, plan_name, test_case_id,
236
340
  test_case_version)
237
341
  test_project_id = project_id(project_name)
238
- test_plan_id = test_plan_id(project_name, plan_name)
342
+ test_plan_id = test_plan_id(project_name, plan_name)
239
343
 
240
344
  result = add_test_case_to_test_plan(test_project_id, test_plan_id,
241
345
  test_case_id, test_case_version)
@@ -1,4 +1,4 @@
1
1
  class TestLinker
2
2
  # test_linker version
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
@@ -6,58 +6,59 @@ class TestLinker
6
6
  # functions.
7
7
  module Wrapper
8
8
 
9
- # Gets a test case by it's internal or external ID.
9
+ # Returns info about the server's TestLink API.
10
10
  #
11
- # @api TestLink API version 1.0
12
- # @param [Hash] options
13
- # @option options [Fixnum,String] testcaseid
14
- # @option options [Fixnum,String] testcaseexternalid
15
- # @option options [Fixnum,String] version The test case version. Default is most recent.
16
- # @return
17
- def test_case(options)
18
- make_call("tl.getTestCase", options, "1.0")
11
+ # @return [String] Info about TestLink API version
12
+ def about
13
+ make_call("tl.about", {}, "1.0b5")
19
14
  end
20
- alias_method :getTestCase, :test_case
21
15
 
22
- # Gets full path from the given node till the top using nodes_hierarchy_table.
16
+ # Adds a test case version to a test plan.
23
17
  #
24
- # @api TestLink API version 1.0
25
- # @param [Fixnum,String] node_id
18
+ # @param [Fixnum,String] project_id
19
+ # @param [Fixnum,String] plan_id
20
+ # @param [Fixnum,String] test_case_external_id
21
+ # @param [Fixnum,String] test_case_version
22
+ # @param [Hash] options Optional parameters for the method.
23
+ # @option options [String] urgency
24
+ # @option options [Fixnum] executionorder
25
+ # @option options [Fixnum] platformid Only if test plan has no platforms.
26
+ # (TestLink API >=1.0)
26
27
  # @return
27
- def full_path node_id
28
- args = { :nodeID => node_id }
29
- make_call("tl.getFullPath", args, "1.0")
28
+ def add_test_case_to_test_plan(project_id, plan_id, test_case_external_id,
29
+ test_case_version, options={})
30
+ args = { :testprojectid => project_id, :testplanid => plan_id,
31
+ :testcaseexternalid => test_case_external_id,
32
+ :version => test_case_version }
33
+ args.merge! options
34
+ make_call("tl.addTestCaseToTestPlan", args, "1.0b5")
30
35
  end
31
- alias_method :getFullPath, :full_path
36
+ alias_method :addTestCaseToTestPlan, :add_test_case_to_test_plan
32
37
 
33
- # Gets a test suite by the given ID.
38
+ # Assign Requirements to a test case. Capable of assigning multiple
39
+ # requirements. Requirements can belong to different Requirement Specs.
34
40
  #
35
- # @api TestLink API version 1.0
36
- # @param [Fixnum,String] suite_id
41
+ # @param [Fixnum,String] project_id
42
+ # @param [Fixnum,String] test_case_external_id
43
+ # @param [String] requirements
37
44
  # @return
38
- def test_suite_by_id suite_id
39
- args = { :testsuiteid => suite_id }
40
- make_call("tl.getTestSuiteByID", args, "1.0")
41
- end
42
- alias_method :getTestSuiteByID, :test_suite_by_id
43
-
44
- # @api TestLink API version 1.0
45
- # @param [Fixnum,String] execution_id
46
- # @return [Hash] "status", "id", "message"
47
- def delete_execution execution_id
48
- args = { :executionid => execution_id }
49
- make_call("tl.deleteExecution", args, "1.0")
45
+ def assign_requirements(project_id, test_case_external_id, requirements)
46
+ args = { :testcaseexternalid => test_case_external_id,
47
+ :testprojectid => project_id, :requirements => requirements }
48
+ make_call("tl.assignRequirements", args, "1.0b5")
50
49
  end
51
- alias_method :deleteExecution, :delete_execution
50
+ alias_method :assignRequirements, :assign_requirements
52
51
 
53
- # @api TestLink API version 1.0
54
- # @param [String] user_name
55
- # @return [Boolean,Hash] true if user exists, otherwise an error structure.
56
- def does_user_exist user_name
57
- args = { :user => user_name }
58
- make_call("tl.doesUserExist", args, "1.0")
52
+ # Gets a list of builds within a test plan.
53
+ #
54
+ # @param [Fixnum,String] plan_id ID of the plan to get builds for.
55
+ # @return [Array<Hash>] List of all builds for the plan and their associated
56
+ # info.
57
+ def builds_for_test_plan plan_id
58
+ args = { :testplanid => plan_id }
59
+ make_call("tl.getBuildsForTestPlan", args, "1.0b5")
59
60
  end
60
- alias_method :doesUserExist, :does_user_exist
61
+ alias_method :getBuildsForTestPlan, :builds_for_test_plan
61
62
 
62
63
  # Checks if the given Developer Key exist.
63
64
  #
@@ -70,193 +71,169 @@ class TestLinker
70
71
  end
71
72
  alias_method :checkDevKey, :check_dev_key
72
73
 
73
- # Uploads an attachment for a test case execution.
74
+ # Creates a new build for a specific test plan.
74
75
  #
75
- # @api TestLink API version 1.0
76
- # @param [Fixnum,String] execution_id
77
- # @param [String] file_name
78
- # @param [String] mime_type
79
- # @param [String] content The Base64 encoded content of the attachment.
80
- # @param [Hash] options
81
- # @option options [String] title
82
- # @option options [String] description
76
+ # @param [Fixnum,String] plan_id
77
+ # @param [String] build_name
78
+ # @param [String] build_notes
83
79
  # @return
84
- def upload_execution_attachment(execution_id, file_name, mime_type, content,
85
- options={})
86
- args = { :executionid => execution_id, :filename => file_name,
87
- :filetype => mime_type, :content => content }
88
- args.merge! options
89
- make_call("tl.uploadExecutionAttachment", args, "1.0")
80
+ def create_build(plan_id, build_name, build_notes)
81
+ args = { :testplanid => plan_id, :buildname => build_name,
82
+ :buildnotes => build_notes }
83
+ make_call("tl.createBuild", args, "1.0b5")
90
84
  end
91
- alias_method :uploadExecutionAttachment, :upload_execution_attachment
85
+ alias_method :createBuild, :create_build
92
86
 
93
- # Uploads an attachment for a Requirement. The attachment content must be
94
- # Base64 encoded by the client before sending it.
95
- #
96
- # @api TestLink API version 1.0
97
- # @param [Fixnum,String] requirement_id
98
- # @param [String] file_name
99
- # @param [String] mime_type
100
- # @param [String] content The Base64 encoded content of the attachment.
87
+ # @param [String] project_name
88
+ # @param [String] test_case_prefix
101
89
  # @param [Hash] options
102
- # @option options [String] title
103
- # @option options [String] description
90
+ # @option options [String] notes
91
+ # @option options [Hash] options ALL int treated as boolean:
92
+ # requirementsEnabled, testPriorityEnabled, automationEnabled,
93
+ # inventoryEnabled
94
+ # @option options [Fixnum] active
95
+ # @option options [Fixnum] public
104
96
  # @return
105
- def upload_requirement_attachment(requirement_id, file_name, mime_type,
106
- content, options={})
107
- args = { :requirementid => requirement_id, :filename => file_name,
108
- :filetype => mime_type, :content => content }
97
+ def create_project(project_name, test_case_prefix, options={})
98
+ args = { :testprojectname => project_name, :testcaseprefix => test_case_prefix }
109
99
  args.merge! options
110
- make_call("tl.uploadRequirementAttachment", args, "1.0")
100
+ make_call("tl.createTestProject", args, "1.0b5")
111
101
  end
112
- alias_method :uploadRequirementAttachment, :upload_requirement_attachment
102
+ alias_method :createTestProject, :create_project
113
103
 
114
- # Uploads an attachment for a Requirement Specification. The attachment
115
- # content must be Base64 encoded by the client before sending it.
116
- #
117
- # @api TestLink API version 1.0
118
- # @param [Fixnum,String] requirement_specification_id
119
- # @param [String] file_name
120
- # @param [String] mime_type
121
- # @param [String] content The Base64 encoded content of the attachment.
104
+ # @param [Fixnum,String] project_id
105
+ # @param [Fixnum,String] suite_id
106
+ # @param [String] test_case_name
107
+ # @param [String] test_case_summary
108
+ # @param [String] test_case_steps
109
+ # @param [String] test_case_expected_results
110
+ # @param [String] login
122
111
  # @param [Hash] options
123
- # @option options [String] title
124
- # @option options [String] description
112
+ # @option options [String] preconditions
113
+ # @option options [String] execution
114
+ # @option options [Fixnum] order
115
+ # @option options [Fixnum,String] internalid
116
+ # @option options [Boolean] checkduplicatedname
117
+ # @option options [String] actiononduplicatedname
118
+ # @option options [String] executiontype
125
119
  # @return
126
- def upload_requirement_specification_attachment(requirement_specification_id,
127
- file_name, mime_type, content, options={})
128
- args = { :reqspecid => requirement_specification_id, :filename => file_name,
129
- :filetype => mime_type, :content => content }
120
+ def create_test_case(project_id, suite_id, test_case_name, test_case_summary,
121
+ test_case_steps, test_case_expected_results, login, options={})
122
+ args = { :testcasename => test_case_name,
123
+ :testsuiteid => suite_id,
124
+ :testprojectid => project_id,
125
+ :authorlogin => login,
126
+ :summary => test_case_summary,
127
+ :steps => test_case_steps,
128
+ :expectedresults => test_case_expected_results }
130
129
  args.merge! options
131
- make_call("tl.uploadRequirementSpecificationAttachment", args, "1.0")
130
+ make_call("tl.createTestCase", args, "1.0b5")
132
131
  end
133
- alias_method :uploadRequirementSpecificationAttachment,
134
- :upload_requirement_specification_attachment
132
+ alias_method :createTestCase, :create_test_case
135
133
 
136
- # Assign Requirements to a test case. Capable of assigning multiple
137
- # requirements. Requirements can belong to different Requirement Specs.
138
- #
139
- # @param [Fixnum,String] project_id
140
- # @param [Fixnum,String] test_case_external_id
141
- # @param [String] requirements
134
+ # @api TestLink API version 1.0
135
+ # @param [String] project_name
136
+ # @param [String] plan_name
137
+ # @param [Hash] options
138
+ # @option options [String] notes
139
+ # @option options [String] active Defaults to 1.
140
+ # @option options [String] public Defaults to 1.
142
141
  # @return
143
- def assign_requirements(project_id, test_case_external_id, requirements)
144
- args = { :testcaseexternalid => test_case_external_id,
145
- :testprojectid => project_id, :requirements => requirements }
146
- make_call("tl.assignRequirements", args, "1.0b5")
142
+ def create_test_plan(project_name, plan_name, options={})
143
+ args = { :testplanname => plan_name, :testprojectname => project_name }
144
+ args.merge! options
145
+ make_call('tl.createTestPlan', args, "1.0")
147
146
  end
148
- alias_method :assignRequirements, :assign_requirements
147
+ alias_method :createTestPlan, :create_test_plan
149
148
 
150
- # Uploads an attachment for a Test Project. The attachment must be Base64
151
- # encoded by the client before sending it.
152
- #
153
- # @api TestLink API version 1.0
154
149
  # @param [Fixnum,String] project_id
155
- # @param [String] file_name
156
- # @param [String] mime_type
157
- # @param [String] content The Base64 encoded content of the attachment.
150
+ # @param [String] suite_name
151
+ # @param [String] details
158
152
  # @param [Hash] options
159
- # @option options [String] title
160
- # @option options [String] description
161
- # @return
162
- def upload_project_attachment(project_id, file_name, mime_type, content,
163
- options={})
164
- args = { :testprojectid => project_id, :filename => file_name,
165
- :filetype => mime_type, :content => content }
153
+ # @option options [Fixnum,String] parentid Defaults to top level.
154
+ # @option options [Fixnum] order Order inside parent container.
155
+ # @option options [Boolean] checkduplicatedname Check if there siblings with
156
+ # the same name. Defaults to true.
157
+ # @option options [Boolean] actiononduplicatedname Applicable only if
158
+ # checkduplicatedname = true.
159
+ # @return [Array<Hash>] Info about results of test suite creation.
160
+ def create_test_suite(project_id, suite_name, details, options={})
161
+ args = { :testprojectid => project_id, :testsuitename => suite_name,
162
+ :details => details }
166
163
  args.merge! options
167
- make_call("tl.uploadTestProjectAttachment", args, "1.0")
164
+ make_call('tl.createTestSuite', args, "1.0b5")
168
165
  end
169
- alias_method :uploadTestProjectAttachment, :upload_project_attachment
166
+ alias_method :createTestSuite, :create_test_suite
170
167
 
171
- # Uploads an attachment for a Test Suite. The attachment must be Base64
172
- # encoded by the client before sending it.
173
- #
174
168
  # @api TestLink API version 1.0
175
- # @param [Fixnum,String] suite_id
176
- # @param [String] file_name
177
- # @param [String] mime_type
178
- # @param [String] content The Base64 encoded content of the attachment.
179
- # @param [Hash] options
180
- # @option options [String] title
181
- # @option options [String] description
182
- # @return
183
- def upload_test_suite_attachment(suite_id, file_name, mime_type, content,
184
- options={})
185
- args = { :testsuiteid => suite_id, :filename => file_name,
186
- :filetype => mime_type, :content => content }
187
- args.merge! options
188
- make_call("tl.uploadTestSuiteAttachment", args, "1.0")
169
+ # @param [Fixnum,String] execution_id
170
+ # @return [Hash] "status", "id", "message"
171
+ def delete_execution execution_id
172
+ args = { :executionid => execution_id }
173
+ make_call("tl.deleteExecution", args, "1.0")
189
174
  end
190
- alias_method :uploadTestSuiteAttachment, :upload_test_suite_attachment
175
+ alias_method :deleteExecution, :delete_execution
191
176
 
192
- # Uploads an attachment for a Test Case. The attachment must be Base64
193
- # encoded by the client before sending it.
194
- #
195
177
  # @api TestLink API version 1.0
196
- # @param [Fixnum,String] test_case_id
197
- # @param [String] file_name
198
- # @param [String] mime_type
199
- # @param [String] content The Base64 encoded content of the attachment.
200
- # @param [Hash] options
201
- # @option options [String] title
202
- # @option options [String] description
203
- # @return
204
- def upload_test_case_attachment(test_case_id, file_name, mime_type, content,
205
- options={})
206
- args = { :testcaseid => test_case_id, :filename => file_name,
207
- :filetype => mime_type, :content => content }
208
- args.merge! options
209
- make_call("tl.uploadTestCaseAttachment", args, "1.0")
178
+ # @param [String] user_name
179
+ # @return [Boolean,Hash] true if user exists, otherwise an error structure.
180
+ def does_user_exist user_name
181
+ args = { :user => user_name }
182
+ make_call("tl.doesUserExist", args, "1.0")
210
183
  end
211
- alias_method :uploadTestCaseAttachment, :upload_test_case_attachment
184
+ alias_method :doesUserExist, :does_user_exist
212
185
 
213
- # Uploads an attachment for specified table. You must specify the table that
214
- # the attachment is connected (nodes_hierarchy, builds, etc) and the foreign
215
- # key id in this table The attachment must be Base64 encoded by the client
216
- # before sending it.
186
+ # Gets the set of test suites from the top level of the test project tree.
187
+ #
188
+ # @param [Fixnum,String] project_id ID of the project to get suites for.
189
+ # @return [Array<Hash>] List of first level suites in project and their
190
+ # associated info.
191
+ def first_level_test_suites_for_project project_id
192
+ args = { :testprojectid => project_id }
193
+ make_call("tl.getFirstLevelTestSuitesForTestProject", args, "1.0b5")
194
+ end
195
+ alias_method :getFirstLevelTestSuitesForTestProject,
196
+ :first_level_test_suites_for_project
197
+
198
+ # Gets full path from the given node till the top using nodes_hierarchy_table.
217
199
  #
218
200
  # @api TestLink API version 1.0
219
- # @param [Fixnum,String] foreign_key_id
220
- # @param [String] foreign_key_table
221
- # @param [String] file_name
222
- # @param [String] mime_type
223
- # @param [String] content The Base64 encoded content of the attachment.
224
- # @param [Hash] options
225
- # @option options [String] title
226
- # @option options [String] description
201
+ # @param [Fixnum,String] node_id
227
202
  # @return
228
- def upload_attachment(foreign_key_id, foreign_key_table, file_name,
229
- mime_type, content, options={})
230
- args = { :fkid => foreign_key_id, :fktable => foreign_key_table,
231
- :filename => file_name, :filetype => mime_type, :content => content }
232
- args.merge! options
233
- make_call("tl.uploadAttachment", args, "1.0")
203
+ def full_path node_id
204
+ args = { :nodeID => node_id }
205
+ make_call("tl.getFullPath", args, "1.0")
234
206
  end
235
- alias_method :uploadAttachment, :upload_attachment
207
+ alias_method :getFullPath, :full_path
236
208
 
237
- # Basic connectivity test.
238
- #
239
- # @return [String] "Hello!"
240
- def say_hello
241
- make_call("tl.sayHello", {}, "1.0b5")
209
+ # @param [Fixnum,String] plan_id
210
+ # @param [Fixnum,String] build_id
211
+ # @param [Fixnum,String] test_case_id
212
+ # @return [Array<Hash>] Single element Array containing the result Hash.
213
+ def last_execution_result(plan_id, build_id, test_case_id)
214
+ args = { :testplanid => plan_id, :testcaseid => test_case_id, :buildid => build_id }
215
+ make_call("tl.getLastExecutionResult", args, "1.0b5")
242
216
  end
243
- alias_method :sayHello, :say_hello
244
- alias_method :ping, :say_hello
217
+ alias_method :getLastExecutionResult, :last_execution_result
245
218
 
246
- # Sends a message to the server to have it repeated back.
247
- #
248
- # @param [String] message The message to get the server to repeat back.
249
- # @return [String] The message sent to the server.
250
- def repeat message
251
- make_call("tl.repeat", { :str => message }, "1.0b5")
219
+ # @param [Fixnum,String] plan_id ID of the plan to get build for.
220
+ # @return [Hash] Info for the latest build for the given test plan.
221
+ def latest_build_for_test_plan plan_id
222
+ args = { :testplanid => plan_id }
223
+ make_call("tl.getLatestBuildForTestPlan", args, "1.0b5")
252
224
  end
225
+ alias_method :getLatestBuildForTestPlan, :latest_build_for_test_plan
253
226
 
254
- # Returns info about the server's TestLink API.
227
+ # Info about a test project with a given name.
255
228
  #
256
- # @return [String] Info about TestLink API version
257
- def about
258
- make_call("tl.about", {}, "1.0b5")
229
+ # @api TestLink API version 1.0
230
+ # @param [String] project_name Name of the project to search for.
231
+ # @return [Array<Hash>] Info on matching project.
232
+ def project_by_name project_name
233
+ args = { :testprojectname => project_name }
234
+ make_call('tl.getTestProjectByName', args, "1.0")
259
235
  end
236
+ alias_method :getTestProjectByName, :project_by_name
260
237
 
261
238
  # Gets a list of all projects.
262
239
  #
@@ -267,95 +244,177 @@ class TestLinker
267
244
  end
268
245
  alias_method :getProjects, :projects
269
246
 
270
- # Gets a list of test plans within a project.
247
+ # Sends a message to the server to have it repeated back.
271
248
  #
272
- # @param [Fixnum,String] project_id ID of the project to retrieve plans.
273
- # @return [Array<Hash>] Array of all plans in a project and their associated
274
- # info.
275
- # @raise [TestLinker::Error] If a project by the given ID doesn't exist.
276
- def test_plans project_id
277
- args = { :testprojectid => project_id }
278
- response = make_call("tl.getProjectTestPlans", args, "1.0b5")
279
- response == "" ? [{}] : response
249
+ # @param [String] message The message to get the server to repeat back.
250
+ # @return [String] The message sent to the server.
251
+ def repeat message
252
+ make_call("tl.repeat", { :str => message }, "1.0b5")
280
253
  end
281
- alias_method :getProjectTestPlans, :test_plans
282
254
 
283
- # Info about a test project with a given name.
255
+ # Sets result in TestLink by test case ID and test plan ID.
256
+ # NOTE: will guess at last build, needs to be set to guarantee accuracy.
257
+ # NOTE: Renamed to setTestCaseExecutionResult in version 1.0.
284
258
  #
285
- # @api TestLink API version 1.0
286
- # @param [String] project_name Name of the project to search for.
287
- # @return [Array<Hash>] Info on matching project.
288
- def project_by_name project_name
289
- args = { :testprojectname => project_name }
290
- make_call('tl.getTestProjectByName', args, "1.0")
291
- end
292
- alias_method :getTestProjectByName, :project_by_name
259
+ # @see #test_case_execution_result=
260
+ # @version TestLink API version 1.0 Beta 5
261
+ # @param [Fixnum,String] plan_id ID of the test plan to post results to.
262
+ # @param [Fixnum,String] test_case_id ID of the test case to post results to.
263
+ # @param [String] status 'p', 'f', or 'b' for Pass/Fail/Block
264
+ # @param [Hash] options
265
+ # @option options [Fixnum,String] buildid ID of the build to post results to.
266
+ # @option options [Fixnum,String] buildname Name of the build to post results to.
267
+ # @option options [Fixnum,String] bugid ID of the bug to link results to.
268
+ # @option options [Boolean] guess Defines whether to guess optional params
269
+ # or require them explicitly. Defaults to true.
270
+ # @option options [Fixnum,String] platformid ID of the platform to associate with the
271
+ # result. (TestLink API >=1.0)
272
+ # @option options [String] customfields i.e. "NAME: Steve Loveless\n"
273
+ # (TestLink API >=1.0)
274
+ # @option options [String] notes ?
275
+ # @return [Hash] "status" of posting, "id" of the execution, "message"
276
+ # giving success or failure info.
277
+ # @raise [TestLinker::Error] If result fails to be posted for any reason.
278
+ def report_test_case_result(plan_id, test_case_id, status, options={})
279
+ if @version >= "1.0"
280
+ message = "Method not supported in version #{@version}. "
281
+ message << "Use #test_case_execution_result="
282
+ raise TestLinker::Error, message
283
+ end
293
284
 
294
- # Gets the test plan with the given name.
295
- #
296
- # @api TestLink API version 1.0
297
- # @param [String] project_name Name of the project the plan is in.
298
- # @param [String] plan_name Name of the plan to search for.
299
- # @return [Array<Hash>] Info on matching plan.
300
- def test_plan_by_name(project_name, plan_name)
301
- args = { :testplanname => plan_name, :testprojectname => project_name }
302
- make_call('tl.getTestPlanByName', args, "1.0")
285
+ args = { :testcaseid => test_case_id, :testplanid => plan_id,
286
+ :status => status, :guess => true }
287
+ args.merge! options
288
+ result = @server.call("tl.reportTCResult", args).first
289
+
290
+ unless result['message'] == 'Success!'
291
+ raise TestLinker::Error, "#{result['code']}: #{result['message']}"
292
+ end
293
+
294
+ result
303
295
  end
304
- alias_method :getTestPlanByName, :test_plan_by_name
296
+ alias_method :reportTCResult, :report_test_case_result
305
297
 
306
- # List test suites within a test plan alphabetically.
298
+ # Basic connectivity test.
307
299
  #
308
- # @param [Fixnum,String] plan_id ID of the plan to get suites for.
309
- # @return [Array<Hash>] List of all suites in plan and their associated info.
310
- def test_suites_for_test_plan plan_id
311
- args = { :testplanid => plan_id }
312
- make_call("tl.getTestSuitesForTestPlan", args, "1.0b5")
300
+ # @return [String] "Hello!"
301
+ def say_hello
302
+ make_call("tl.sayHello", {}, "1.0b5")
313
303
  end
314
- alias_method :getTestSuitesForTestPlan, :test_suites_for_test_plan
304
+ alias_method :sayHello, :say_hello
305
+ alias_method :ping, :say_hello
315
306
 
316
- # List test suites within a test plan alphabetically.
307
+ # Gets a test case by it's internal or external ID.
317
308
  #
318
309
  # @api TestLink API version 1.0
319
- # @param [Fixnum,String] plan_id ID of the plan to get suites for.
320
- # @return [Array<Hash>] List of all suites in plan and their associated info.
321
- def test_plan_platforms plan_id
322
- args = { :testplanid => plan_id }
323
- make_call("tl.getTestPlanPlatforms", args, "1.0")
310
+ # @param [Hash] options
311
+ # @option options [Fixnum,String] testcaseid
312
+ # @option options [Fixnum,String] testcaseexternalid
313
+ # @option options [Fixnum,String] version The test case version. Default is most recent.
314
+ # @return
315
+ def test_case(options)
316
+ make_call("tl.getTestCase", options, "1.0")
324
317
  end
325
- alias_method :getTestPlanPlatforms, :test_plan_platforms
318
+ alias_method :getTestCase, :test_case
326
319
 
327
- # Gets a list of test suites that are direct children of the given test suite.
320
+ # Gets attachments for specified test case.
328
321
  #
329
- # @api TestLink API version 1.0
330
- # @param [Fixnum,String] suite_id ID of the suite to get suites for.
331
- # @return [Array<Hash>] List of all suites in plan and their associated info.
332
- def test_suites_for_test_suite suite_id
333
- args = { :testsuiteid => suite_id }
334
- make_call("tl.getTestSuitesForTestSuite", args, "1.0")
322
+ # @param [Hash] options
323
+ # @param [Fixnum,String] testcaseid If not present, testcaseexternalid must be called.
324
+ # @param [Fixnum,String] testcaseexternalid If not present, testcaseid must be called.
325
+ # @return [String]
326
+ def test_case_attachments options
327
+ make_call("tl.getTestCaseAttachments", options, "1.0b5")
335
328
  end
336
- alias_method :getTestSuitesForTestSuite, :test_suites_for_test_suite
329
+ alias_method :getTestCaseAttachments, :test_case_attachments
337
330
 
338
- # Gets the set of test suites from the top level of the test project tree.
339
- #
340
- # @param [Fixnum,String] project_id ID of the project to get suites for.
341
- # @return [Array<Hash>] List of first level suites in project and their
342
- # associated info.
343
- def first_level_test_suites_for_project project_id
344
- args = { :testprojectid => project_id }
345
- make_call("tl.getFirstLevelTestSuitesForTestProject", args, "1.0b5")
331
+ # @param [Fixnum,String] project_id
332
+ # @param [Fixnum,String] test_case_external_id
333
+ # @param [Fixnum] custom_field_name
334
+ # @param [Hash] options
335
+ # @option options [String] details Changes output information. If null or 'value',
336
+ # returns just a value; if 'full', returns a hash with all custom field definition,
337
+ # plus value and internal test case id; if 'simple', returns value plus custom
338
+ # field name, label, and type (as code).
339
+ # @return [Array<Hash>]
340
+ def test_case_custom_field_design_value(project_id, test_case_external_id,
341
+ custom_field_name, options={})
342
+ args = { :testprojectid => project_id,
343
+ :testcaseexternalid => test_case_external_id,
344
+ :customfieldname => custom_field_name }
345
+ args.merge! options
346
+ make_call("tl.getTestCaseCustomFieldDesignValue", args, "1.0b5")
346
347
  end
347
- alias_method :getFirstLevelTestSuitesForTestProject,
348
- :first_level_test_suites_for_project
348
+ alias_method :getTestCaseCustomFieldDesignValue, :test_case_custom_field_design_value
349
349
 
350
- # Info about test cases within a test plan.
350
+ # Sets result in TestLink by test case ID and test plan ID.
351
+ # NOTE: will guess at last build, needs to be set to guarantee accuracy.
351
352
  #
352
- # @param [Fixnum,String] plan_id ID of the plan to get test cases for.
353
+ # @see #report_test_case_result
354
+ # @api TestLink API version 1.0
355
+ # @param [String] plan_id ID of the test plan to post results to.
356
+ # @param [String] test_case_id ID of the test case to post results to.
357
+ # @param [String] status 'p', 'f', or 'b' for Pass/Fail/Block
353
358
  # @param [Hash] options
354
- # @option options [Fixnum,String] testcaseid
355
- # @option options [Fixnum,String] buildid
356
- # @option options [Fixnum,String] keywordid (mutually exclusive with keywords)
357
- # @option options [Fixnum] keywords (mutually exclusive with keywordid)
358
- # (TestLink API >=1.0)
359
+ # @option options [Fixnum] buildid ID of the build to post results to.
360
+ # @option options [String] buildname Name of the build to post results to.
361
+ # @option options [Fixnum] bugid ID of the bug to link results to.
362
+ # @option options [Boolean] guess Defines whether to guess optinal params or require them.
363
+ # @option options [String] notes ?
364
+ # @option options [String] platformid (version 1.0)
365
+ # @option options [String] platformid (version 1.0)
366
+ # @option options [String] customfields (version 1.0)
367
+ # @option options [String] overwrite (version 1.0)
368
+ # @return [Hash] "status" of posting, "id" of the execution, "message"
369
+ # giving success or failure info.
370
+ # @raise [TestLinker::Error] If result fails to be posted for any reason.
371
+ def test_case_execution_result=(plan_id, test_case_id, status, options={})
372
+ if @version < "1.0"
373
+ message = "Method not supported in version #{@version}. "
374
+ message << "Use #report_test_case_result"
375
+ raise TestLinker::Error, message
376
+ end
377
+
378
+ args = { :testcaseid => test_case_id, :testplanid => plan_id,
379
+ :status => status, :guess => true }
380
+ args.merge! options
381
+ result = make_call("tl.setTestCaseExecutionResult", args, "1.0").first
382
+
383
+ unless result[:message] == 'Success!'
384
+ raise TestLinker::Error, "#{result['code']}: #{result['message']}"
385
+ end
386
+
387
+ result
388
+ end
389
+ alias_method :setTestCaseExecutionResult, :test_case_execution_result=
390
+
391
+ # Info about test case by name.
392
+ # CAUTION: returns multiple values if test case is used more than once.
393
+ #
394
+ # @param [String] test_case_name Name to search across TL DB.
395
+ # @param [Hash] options
396
+ # @option options [String] testprojectname
397
+ # @option options [String] testsuitename
398
+ # @option options [String] testcasepathname
399
+ # @raise [TestLinker::Error] When test case name doesn't exist.
400
+ # @return [Array<Hash>] List of all test cases in the DB matching
401
+ # test_case_name and their associated info.
402
+ def test_case_id_by_name(test_case_name, options={})
403
+ args = { :testcasename => test_case_name }
404
+ args.merge! options
405
+ make_call("tl.getTestCaseIDByName", args, "1.0b5")
406
+ end
407
+ alias_method :getTestCaseIDByName, :test_case_id_by_name
408
+
409
+ # Info about test cases within a test plan.
410
+ #
411
+ # @param [Fixnum,String] plan_id ID of the plan to get test cases for.
412
+ # @param [Hash] options
413
+ # @option options [Fixnum,String] testcaseid
414
+ # @option options [Fixnum,String] buildid
415
+ # @option options [Fixnum,String] keywordid (mutually exclusive with keywords)
416
+ # @option options [Fixnum] keywords (mutually exclusive with keywordid)
417
+ # (TestLink API >=1.0)
359
418
  # @option options [String] executed
360
419
  # @option options [String] assignedto
361
420
  # @option options [String] executestatus
@@ -384,293 +443,234 @@ class TestLinker
384
443
  end
385
444
  alias_method :getTestCasesForTestSuite, :test_cases_for_test_suite
386
445
 
387
- # Gets the summarized results grouped by platform.
446
+ # Gets the test plan with the given name.
388
447
  #
389
448
  # @api TestLink API version 1.0
390
- # @param [Fixnum,String] plan_id
391
- # @return [Hash] Contains "type" => platform, "total_tc" => X, "details =>
392
- # Array of counts.
393
- def totals_for_test_plan plan_id
394
- args = { :testplanid => plan_id }
395
- make_call("tl.getTotalsForTestPlan", args, "1.0")
449
+ # @param [String] project_name Name of the project the plan is in.
450
+ # @param [String] plan_name Name of the plan to search for.
451
+ # @return [Array<Hash>] Info on matching plan.
452
+ def test_plan_by_name(project_name, plan_name)
453
+ args = { :testplanname => plan_name, :testprojectname => project_name }
454
+ make_call('tl.getTestPlanByName', args, "1.0")
396
455
  end
397
- alias_method :getTotalsForTestPlan, :totals_for_test_plan
456
+ alias_method :getTestPlanByName, :test_plan_by_name
398
457
 
399
- # Gets attachments for specified test case.
458
+ # List test suites within a test plan alphabetically.
400
459
  #
401
- # @param [Hash] options
402
- # @param [Fixnum,String] testcaseid If not present, testcaseexternalid must be called.
403
- # @param [Fixnum,String] testcaseexternalid If not present, testcaseid must be called.
404
- # @return [String]
405
- def test_case_attachments options
406
- make_call("tl.getTestCaseAttachments", options, "1.0b5")
460
+ # @api TestLink API version 1.0
461
+ # @param [Fixnum,String] plan_id ID of the plan to get suites for.
462
+ # @return [Array<Hash>] List of all suites in plan and their associated info.
463
+ def test_plan_platforms plan_id
464
+ args = { :testplanid => plan_id }
465
+ make_call("tl.getTestPlanPlatforms", args, "1.0")
407
466
  end
408
- alias_method :getTestCaseAttachments, :test_case_attachments
467
+ alias_method :getTestPlanPlatforms, :test_plan_platforms
409
468
 
410
- # @param [Fixnum,String] project_id
411
- # @param [Fixnum,String] test_case_external_id
412
- # @param [Fixnum] custom_field_name
413
- # @param [Hash] options
414
- # @option options [String] details Changes output information. If null or 'value',
415
- # returns just a value; if 'full', returns a hash with all custom field definition,
416
- # plus value and internal test case id; if 'simple', returns value plus custom
417
- # field name, label, and type (as code).
418
- # @return [Array<Hash>]
419
- def test_case_custom_field_design_value(project_id, test_case_external_id,
420
- custom_field_name, options={})
421
- args = { :testprojectid => project_id,
422
- :testcaseexternalid => test_case_external_id,
423
- :customfieldname => custom_field_name }
424
- args.merge! options
425
- make_call("tl.getTestCaseCustomFieldDesignValue", args, "1.0b5")
469
+ # Gets a list of test plans within a project.
470
+ #
471
+ # @param [Fixnum,String] project_id ID of the project to retrieve plans.
472
+ # @return [Array<Hash>] Array of all plans in a project and their associated
473
+ # info.
474
+ # @raise [TestLinker::Error] If a project by the given ID doesn't exist.
475
+ def test_plans project_id
476
+ args = { :testprojectid => project_id }
477
+ response = make_call("tl.getProjectTestPlans", args, "1.0b5")
478
+ response == "" ? [{}] : response
426
479
  end
427
- alias_method :getTestCaseCustomFieldDesignValue, :test_case_custom_field_design_value
480
+ alias_method :getProjectTestPlans, :test_plans
428
481
 
429
- # Info about test case by name.
430
- # CAUTION: returns multiple values if test case is used more than once.
482
+ # Gets a test suite by the given ID.
431
483
  #
432
- # @param [String] test_case_name Name to search across TL DB.
433
- # @param [Hash] options
434
- # @option options [String] testprojectname
435
- # @option options [String] testsuitename
436
- # @option options [String] testcasepathname
437
- # @raise [TestLinker::Error] When test case name doesn't exist.
438
- # @return [Array<Hash>] List of all test cases in the DB matching
439
- # test_case_name and their associated info.
440
- def test_case_id_by_name(test_case_name, options={})
441
- args = { :testcasename => test_case_name }
442
- args.merge! options
443
- make_call("tl.getTestCaseIDByName", args, "1.0b5")
484
+ # @api TestLink API version 1.0
485
+ # @param [Fixnum,String] suite_id
486
+ # @return
487
+ def test_suite_by_id suite_id
488
+ args = { :testsuiteid => suite_id }
489
+ make_call("tl.getTestSuiteByID", args, "1.0")
444
490
  end
445
- alias_method :getTestCaseIDByName, :test_case_id_by_name
491
+ alias_method :getTestSuiteByID, :test_suite_by_id
446
492
 
447
- # @param [Fixnum,String] plan_id
448
- # @param [Fixnum,String] build_id
449
- # @param [Fixnum,String] test_case_id
450
- # @return [Array<Hash>] Single element Array containing the result Hash.
451
- def last_execution_result(plan_id, build_id, test_case_id)
452
- args = { :testplanid => plan_id, :testcaseid => test_case_id, :buildid => build_id }
453
- make_call("tl.getLastExecutionResult", args, "1.0b5")
493
+ # List test suites within a test plan alphabetically.
494
+ #
495
+ # @param [Fixnum,String] plan_id ID of the plan to get suites for.
496
+ # @return [Array<Hash>] List of all suites in plan and their associated info.
497
+ def test_suites_for_test_plan plan_id
498
+ args = { :testplanid => plan_id }
499
+ make_call("tl.getTestSuitesForTestPlan", args, "1.0b5")
454
500
  end
455
- alias_method :getLastExecutionResult, :last_execution_result
501
+ alias_method :getTestSuitesForTestPlan, :test_suites_for_test_plan
456
502
 
457
- # Gets a list of builds within a test plan.
503
+ # Gets a list of test suites that are direct children of the given test suite.
458
504
  #
459
- # @param [Fixnum,String] plan_id ID of the plan to get builds for.
460
- # @return [Array<Hash>] List of all builds for the plan and their associated
461
- # info.
462
- def builds_for_test_plan plan_id
463
- args = { :testplanid => plan_id }
464
- make_call("tl.getBuildsForTestPlan", args, "1.0b5")
505
+ # @api TestLink API version 1.0
506
+ # @param [Fixnum,String] suite_id ID of the suite to get suites for.
507
+ # @return [Array<Hash>] List of all suites in plan and their associated info.
508
+ def test_suites_for_test_suite suite_id
509
+ args = { :testsuiteid => suite_id }
510
+ make_call("tl.getTestSuitesForTestSuite", args, "1.0")
465
511
  end
466
- alias_method :getBuildsForTestPlan, :builds_for_test_plan
512
+ alias_method :getTestSuitesForTestSuite, :test_suites_for_test_suite
467
513
 
468
- # @param [Fixnum,String] plan_id ID of the plan to get build for.
469
- # @return [Hash] Info for the latest build for the given test plan.
470
- def latest_build_for_test_plan plan_id
514
+ # Gets the summarized results grouped by platform.
515
+ #
516
+ # @api TestLink API version 1.0
517
+ # @param [Fixnum,String] plan_id
518
+ # @return [Hash] Contains "type" => platform, "total_tc" => X, "details =>
519
+ # Array of counts.
520
+ def totals_for_test_plan plan_id
471
521
  args = { :testplanid => plan_id }
472
- make_call("tl.getLatestBuildForTestPlan", args, "1.0b5")
522
+ make_call("tl.getTotalsForTestPlan", args, "1.0")
473
523
  end
474
- alias_method :getLatestBuildForTestPlan, :latest_build_for_test_plan
524
+ alias_method :getTotalsForTestPlan, :totals_for_test_plan
475
525
 
476
- # @param [String] project_name
477
- # @param [String] test_case_prefix
526
+ # Uploads an attachment for specified table. You must specify the table that
527
+ # the attachment is connected (nodes_hierarchy, builds, etc) and the foreign
528
+ # key id in this table The attachment must be Base64 encoded by the client
529
+ # before sending it.
530
+ #
531
+ # @api TestLink API version 1.0
532
+ # @param [Fixnum,String] foreign_key_id
533
+ # @param [String] foreign_key_table
534
+ # @param [String] file_name
535
+ # @param [String] mime_type
536
+ # @param [String] content The Base64 encoded content of the attachment.
478
537
  # @param [Hash] options
479
- # @option options [String] notes
480
- # @option options [Hash] options ALL int treated as boolean:
481
- # requirementsEnabled, testPriorityEnabled, automationEnabled,
482
- # inventoryEnabled
483
- # @option options [Fixnum] active
484
- # @option options [Fixnum] public
538
+ # @option options [String] title
539
+ # @option options [String] description
485
540
  # @return
486
- def create_project(project_name, test_case_prefix, options={})
487
- args = { :testprojectname => project_name, :testcaseprefix => test_case_prefix }
541
+ def upload_attachment(foreign_key_id, foreign_key_table, file_name,
542
+ mime_type, content, options={})
543
+ args = { :fkid => foreign_key_id, :fktable => foreign_key_table,
544
+ :filename => file_name, :filetype => mime_type, :content => content }
488
545
  args.merge! options
489
- make_call("tl.createTestProject", args, "1.0b5")
546
+ make_call("tl.uploadAttachment", args, "1.0")
490
547
  end
491
- alias_method :createTestProject, :create_project
548
+ alias_method :uploadAttachment, :upload_attachment
492
549
 
550
+ # Uploads an attachment for a test case execution.
551
+ #
493
552
  # @api TestLink API version 1.0
494
- # @param [String] project_name
495
- # @param [String] plan_name
553
+ # @param [Fixnum,String] execution_id
554
+ # @param [String] file_name
555
+ # @param [String] mime_type
556
+ # @param [String] content The Base64 encoded content of the attachment.
496
557
  # @param [Hash] options
497
- # @option options [String] notes
498
- # @option options [String] active Defaults to 1.
499
- # @option options [String] public Defaults to 1.
558
+ # @option options [String] title
559
+ # @option options [String] description
500
560
  # @return
501
- def create_test_plan(project_name, plan_name, options={})
502
- args = { :testplanname => plan_name, :testprojectname => project_name }
561
+ def upload_execution_attachment(execution_id, file_name, mime_type, content,
562
+ options={})
563
+ args = { :executionid => execution_id, :filename => file_name,
564
+ :filetype => mime_type, :content => content }
503
565
  args.merge! options
504
- make_call('tl.createTestPlan', args, "1.0")
566
+ make_call("tl.uploadExecutionAttachment", args, "1.0")
505
567
  end
506
- alias_method :createTestPlan, :create_test_plan
568
+ alias_method :uploadExecutionAttachment, :upload_execution_attachment
507
569
 
570
+ # Uploads an attachment for a Test Project. The attachment must be Base64
571
+ # encoded by the client before sending it.
572
+ #
573
+ # @api TestLink API version 1.0
508
574
  # @param [Fixnum,String] project_id
509
- # @param [String] suite_name
510
- # @param [String] details
575
+ # @param [String] file_name
576
+ # @param [String] mime_type
577
+ # @param [String] content The Base64 encoded content of the attachment.
511
578
  # @param [Hash] options
512
- # @option options [Fixnum,String] parentid Defaults to top level.
513
- # @option options [Fixnum] order Order inside parent container.
514
- # @option options [Boolean] checkduplicatedname Check if there siblings with
515
- # the same name. Defaults to true.
516
- # @option options [Boolean] actiononduplicatedname Applicable only if
517
- # checkduplicatedname = true.
518
- # @return [Array<Hash>] Info about results of test suite creation.
519
- def create_test_suite(project_id, suite_name, details, options={})
520
- args = { :testprojectid => project_id, :testsuitename => suite_name,
521
- :details => details }
579
+ # @option options [String] title
580
+ # @option options [String] description
581
+ # @return
582
+ def upload_project_attachment(project_id, file_name, mime_type, content,
583
+ options={})
584
+ args = { :testprojectid => project_id, :filename => file_name,
585
+ :filetype => mime_type, :content => content }
522
586
  args.merge! options
523
- make_call('tl.createTestSuite', args, "1.0b5")
587
+ make_call("tl.uploadTestProjectAttachment", args, "1.0")
524
588
  end
525
- alias_method :createTestSuite, :create_test_suite
589
+ alias_method :uploadTestProjectAttachment, :upload_project_attachment
526
590
 
527
- # Creates a new build for a specific test plan.
591
+ # Uploads an attachment for a Requirement. The attachment content must be
592
+ # Base64 encoded by the client before sending it.
528
593
  #
529
- # @param [Fixnum,String] plan_id
530
- # @param [String] build_name
531
- # @param [String] build_notes
532
- # @return
533
- def create_build(plan_id, build_name, build_notes)
534
- args = { :testplanid => plan_id, :buildname => build_name,
535
- :buildnotes => build_notes }
536
- make_call("tl.createBuild", args, "1.0b5")
537
- end
538
- alias_method :createBuild, :create_build
539
-
540
- # @param [Fixnum,String] project_id
541
- # @param [Fixnum,String] suite_id
542
- # @param [String] test_case_name
543
- # @param [String] test_case_summary
544
- # @param [String] test_case_steps
545
- # @param [String] test_case_expected_results
546
- # @param [String] login
594
+ # @api TestLink API version 1.0
595
+ # @param [Fixnum,String] requirement_id
596
+ # @param [String] file_name
597
+ # @param [String] mime_type
598
+ # @param [String] content The Base64 encoded content of the attachment.
547
599
  # @param [Hash] options
548
- # @option options [String] preconditions
549
- # @option options [String] execution
550
- # @option options [Fixnum] order
551
- # @option options [Fixnum,String] internalid
552
- # @option options [Boolean] checkduplicatedname
553
- # @option options [String] actiononduplicatedname
554
- # @option options [String] executiontype
600
+ # @option options [String] title
601
+ # @option options [String] description
555
602
  # @return
556
- def create_test_case(project_id, suite_id, test_case_name, test_case_summary,
557
- test_case_steps, test_case_expected_results, login, options={})
558
- args = { :testcasename => test_case_name,
559
- :testsuiteid => suite_id,
560
- :testprojectid => project_id,
561
- :authorlogin => login,
562
- :summary => test_case_summary,
563
- :steps => test_case_steps,
564
- :expectedresults => test_case_expected_results }
603
+ def upload_requirement_attachment(requirement_id, file_name, mime_type,
604
+ content, options={})
605
+ args = { :requirementid => requirement_id, :filename => file_name,
606
+ :filetype => mime_type, :content => content }
565
607
  args.merge! options
566
- make_call("tl.createTestCase", args, "1.0b5")
608
+ make_call("tl.uploadRequirementAttachment", args, "1.0")
567
609
  end
568
- alias_method :createTestCase, :create_test_case
610
+ alias_method :uploadRequirementAttachment, :upload_requirement_attachment
569
611
 
570
- # Adds a test case version to a test plan.
612
+ # Uploads an attachment for a Requirement Specification. The attachment
613
+ # content must be Base64 encoded by the client before sending it.
571
614
  #
572
- # @param [Fixnum,String] project_id
573
- # @param [Fixnum,String] plan_id
574
- # @param [Fixnum,String] test_case_external_id
575
- # @param [Fixnum,String] test_case_version
576
- # @param [Hash] options Optional parameters for the method.
577
- # @option options [String] urgency
578
- # @option options [Fixnum] executionorder
579
- # @option options [Fixnum] platformid Only if test plan has no platforms.
580
- # (TestLink API >=1.0)
615
+ # @api TestLink API version 1.0
616
+ # @param [Fixnum,String] requirement_specification_id
617
+ # @param [String] file_name
618
+ # @param [String] mime_type
619
+ # @param [String] content The Base64 encoded content of the attachment.
620
+ # @param [Hash] options
621
+ # @option options [String] title
622
+ # @option options [String] description
581
623
  # @return
582
- def add_test_case_to_test_plan(project_id, plan_id, test_case_external_id,
583
- test_case_version, options={})
584
- args = { :testprojectid => project_id, :testplanid => plan_id,
585
- :testcaseexternalid => test_case_external_id,
586
- :version => test_case_version }
624
+ def upload_requirement_specification_attachment(requirement_specification_id,
625
+ file_name, mime_type, content, options={})
626
+ args = { :reqspecid => requirement_specification_id, :filename => file_name,
627
+ :filetype => mime_type, :content => content }
587
628
  args.merge! options
588
- make_call("tl.addTestCaseToTestPlan", args, "1.0b5")
629
+ make_call("tl.uploadRequirementSpecificationAttachment", args, "1.0")
589
630
  end
590
- alias_method :addTestCaseToTestPlan, :add_test_case_to_test_plan
631
+ alias_method :uploadRequirementSpecificationAttachment,
632
+ :upload_requirement_specification_attachment
591
633
 
592
- # Sets result in TestLink by test case ID and test plan ID.
593
- # NOTE: will guess at last build, needs to be set to guarantee accuracy.
594
- # NOTE: Renamed to setTestCaseExecutionResult in version 1.0.
634
+ # Uploads an attachment for a Test Case. The attachment must be Base64
635
+ # encoded by the client before sending it.
595
636
  #
596
- # @see #test_case_execution_result=
597
- # @version TestLink API version 1.0 Beta 5
598
- # @param [Fixnum,String] plan_id ID of the test plan to post results to.
599
- # @param [Fixnum,String] test_case_id ID of the test case to post results to.
600
- # @param [String] status 'p', 'f', or 'b' for Pass/Fail/Block
637
+ # @api TestLink API version 1.0
638
+ # @param [Fixnum,String] test_case_id
639
+ # @param [String] file_name
640
+ # @param [String] mime_type
641
+ # @param [String] content The Base64 encoded content of the attachment.
601
642
  # @param [Hash] options
602
- # @option options [Fixnum,String] buildid ID of the build to post results to.
603
- # @option options [Fixnum,String] buildname Name of the build to post results to.
604
- # @option options [Fixnum,String] bugid ID of the bug to link results to.
605
- # @option options [Boolean] guess Defines whether to guess optional params
606
- # or require them explicitly. Defaults to true.
607
- # @option options [Fixnum,String] platformid ID of the platform to associate with the
608
- # result. (TestLink API >=1.0)
609
- # @option options [String] customfields i.e. "NAME: Steve Loveless\n"
610
- # (TestLink API >=1.0)
611
- # @option options [String] notes ?
612
- # @return [Hash] "status" of posting, "id" of the execution, "message"
613
- # giving success or failure info.
614
- # @raise [TestLinker::Error] If result fails to be posted for any reason.
615
- def report_test_case_result(plan_id, test_case_id, status, options={})
616
- if @version >= "1.0"
617
- message = "Method not supported in version #{@version}. "
618
- message << "Use #test_case_execution_result="
619
- raise TestLinker::Error, message
620
- end
621
-
622
- args = { :testcaseid => test_case_id, :testplanid => plan_id,
623
- :status => status, :guess => true }
643
+ # @option options [String] title
644
+ # @option options [String] description
645
+ # @return
646
+ def upload_test_case_attachment(test_case_id, file_name, mime_type, content,
647
+ options={})
648
+ args = { :testcaseid => test_case_id, :filename => file_name,
649
+ :filetype => mime_type, :content => content }
624
650
  args.merge! options
625
- result = @server.call("tl.reportTCResult", args).first
626
-
627
- unless result['message'] == 'Success!'
628
- raise TestLinker::Error, "#{result['code']}: #{result['message']}"
629
- end
630
-
631
- result
651
+ make_call("tl.uploadTestCaseAttachment", args, "1.0")
632
652
  end
633
- alias_method :reportTCResult, :report_test_case_result
653
+ alias_method :uploadTestCaseAttachment, :upload_test_case_attachment
634
654
 
635
- # Sets result in TestLink by test case ID and test plan ID.
636
- # NOTE: will guess at last build, needs to be set to guarantee accuracy.
655
+ # Uploads an attachment for a Test Suite. The attachment must be Base64
656
+ # encoded by the client before sending it.
637
657
  #
638
- # @see #report_test_case_result
639
658
  # @api TestLink API version 1.0
640
- # @param [String] plan_id ID of the test plan to post results to.
641
- # @param [String] test_case_id ID of the test case to post results to.
642
- # @param [String] status 'p', 'f', or 'b' for Pass/Fail/Block
659
+ # @param [Fixnum,String] suite_id
660
+ # @param [String] file_name
661
+ # @param [String] mime_type
662
+ # @param [String] content The Base64 encoded content of the attachment.
643
663
  # @param [Hash] options
644
- # @option options [Fixnum] buildid ID of the build to post results to.
645
- # @option options [String] buildname Name of the build to post results to.
646
- # @option options [Fixnum] bugid ID of the bug to link results to.
647
- # @option options [Boolean] guess Defines whether to guess optinal params or require them.
648
- # @option options [String] notes ?
649
- # @option options [String] platformid (version 1.0)
650
- # @option options [String] platformid (version 1.0)
651
- # @option options [String] customfields (version 1.0)
652
- # @option options [String] overwrite (version 1.0)
653
- # @return [Hash] "status" of posting, "id" of the execution, "message"
654
- # giving success or failure info.
655
- # @raise [TestLinker::Error] If result fails to be posted for any reason.
656
- def test_case_execution_result=(plan_id, test_case_id, status, options={})
657
- if @version < "1.0"
658
- message = "Method not supported in version #{@version}. "
659
- message << "Use #report_test_case_result"
660
- raise TestLinker::Error, message
661
- end
662
-
663
- args = { :testcaseid => test_case_id, :testplanid => plan_id,
664
- :status => status, :guess => true }
664
+ # @option options [String] title
665
+ # @option options [String] description
666
+ # @return
667
+ def upload_test_suite_attachment(suite_id, file_name, mime_type, content,
668
+ options={})
669
+ args = { :testsuiteid => suite_id, :filename => file_name,
670
+ :filetype => mime_type, :content => content }
665
671
  args.merge! options
666
- result = @server.call("tl.setTestCaseExecutionResult", args).first
667
-
668
- unless result['message'] == 'Success!'
669
- raise TestLinker::Error, "#{result['code']}: #{result['message']}"
670
- end
671
-
672
- result
672
+ make_call("tl.uploadTestSuiteAttachment", args, "1.0")
673
673
  end
674
- alias_method :setTestCaseExecutionResult, :test_case_execution_result=
674
+ alias_method :uploadTestSuiteAttachment, :upload_test_suite_attachment
675
675
  end
676
676
  end