testrail_rspec 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: caf3e56aa6b5f3282ca4782031502ac33f1a9a24
4
- data.tar.gz: 30c176d341f33987bcf8dd745dee4541e62cf02c
3
+ metadata.gz: a309a3c8560f79c8d8d14007533e8b2390f7e223
4
+ data.tar.gz: 43e3a1f3ce7d8239ba75ebe9ee029432b16fbbc4
5
5
  SHA512:
6
- metadata.gz: 561a7ece1fe03c9f4d91125d6f071347cd27e81a2f20b773b5b76ae0561be5aae48aa35fd408526bea4cddfcb15bf8f8bdf90f07eb643bf127851a9b410cc5e1
7
- data.tar.gz: ca1fe5af70bcbbf0df9cf204dfca1e625323533c3ad1498279751dfb6014979f8dc04f9ac92832d3cbedb20f3391606d1a418ae974c66283e116875548a44818
6
+ metadata.gz: c004fc325ba968da4ae437d0a079179b40e7d0a745271bef13478d97bb22880a5608df38b23069841b77686e8cade25e115772c03bb6da27162f1cdf7757e5ea
7
+ data.tar.gz: 2ee15a1484369276635bb168bae6fa341e91edc47dfeb82f0c6871f93c62815874fba0cf46b9b47714636eec339d4960310d55736ff3d6516f8f7981d14e3c3d
data/README.md CHANGED
@@ -28,11 +28,22 @@ via RSpec.configure in spec_helper.rb - describe it in more details when decided
28
28
  add to .rspec file this way:
29
29
 
30
30
  $ --format TestrailExport
31
+ the same for [Parallel Tests][3]
31
32
 
32
33
  or use it from commandline this way:
33
34
 
34
35
  $ rspec spec --format TestrailExport
35
36
 
37
+ ### Customize it
38
+ ##### Test Run name
39
+ Test run names consists of two parts by default:
40
+
41
+ - **TEST_RUN_NAME** envirnment variable value or execution time/date (i.e. **"15 Oct 2014 15:41 CEST"**)
42
+ - suite name (if only it is different then _Master_ which is reserved for single suite projects)
43
+
44
+ example test run name: **15 Oct 2014 15:41 CEST - Test Suite 1**
45
+
46
+
36
47
  ## Contributing
37
48
 
38
49
  1. Fork it ( https://github.com/[my-github-username]/testrail-rspec/fork )
@@ -42,4 +53,5 @@ or use it from commandline this way:
42
53
  5. Create a new Pull Request
43
54
 
44
55
  [1]: http://www.gurock.com/testrail/ "TestRail"
45
- [2]: http://docs.gurock.com/testrail-api2/start "TestRail API"
56
+ [2]: http://docs.gurock.com/testrail-api2/start "TestRail API"
57
+ [3]: https://github.com/grosser/parallel_tests "Parallel Tests"
@@ -20,7 +20,7 @@ class TestrailExport < RSpec::Core::Formatters::BaseTextFormatter
20
20
 
21
21
  def initialize(output)
22
22
  @options = {}
23
- @project_id = nil
23
+ @project = nil
24
24
  super(output)
25
25
  end
26
26
 
@@ -28,8 +28,8 @@ class TestrailExport < RSpec::Core::Formatters::BaseTextFormatter
28
28
  def start(notification)
29
29
  @options = RSpec.configuration.testrail_formatter_options
30
30
  @client = Testrail::Client.new(@options)
31
- @client.get_projects.each { |project| @project_id = project['id'] if project['name'] == @options[:project] }
32
- @start_time_str = start_timestamp
31
+ @client.get_projects.each { |project| @project = project if project['name'] == @options[:project] }
32
+ @run_name = ENV['TEST_RUN_NAME'] || start_timestamp
33
33
 
34
34
  puts "TestRail Exporter [INFO] Executing #{notification.count} tests. Loaded in #{notification.load_time}"
35
35
 
@@ -101,14 +101,15 @@ class TestrailExport < RSpec::Core::Formatters::BaseTextFormatter
101
101
  end
102
102
 
103
103
  def dump_summary(notification)
104
+ @client.get_projects.each { |project| @project = project if project['name'] == @options[:project] } unless @project
104
105
  # Create project if it is not present / could do it setting controlled
105
- if @project_id.nil?
106
+ if @project.nil?
106
107
  puts "TestRail Exporter [INFO] Creating project: #{@options[:project]}"
107
- @project_id = @client.add_project(@options[:project])['id']
108
+ @project = @client.add_project(@options[:project])
108
109
  end
109
110
 
110
111
  suites = Hash.new do |h,k|
111
- h[k] = Tree::TreeNode.new(k, @client.find_or_create_suite(k, @project_id) )
112
+ h[k] = Tree::TreeNode.new(k, @client.find_or_create_suite(k, @project['id']) )
112
113
  end
113
114
 
114
115
 
@@ -116,7 +117,7 @@ class TestrailExport < RSpec::Core::Formatters::BaseTextFormatter
116
117
  build_hierarchy_tree!(suites, example)
117
118
  end
118
119
 
119
- suites.each { |_, suite| update_test_run(suite) }
120
+ suites.each { |_, suite| update_test_run(suite, @run_name) }
120
121
 
121
122
  super
122
123
  end
@@ -139,7 +140,7 @@ class TestrailExport < RSpec::Core::Formatters::BaseTextFormatter
139
140
 
140
141
  def build_hierarchy_tree!(suites, example)
141
142
  path = get_path_for(example)
142
-
143
+ path.unshift('Master') if @project['suite_mode'] == 1
143
144
  parent_node = suite_node = suites[path.shift]
144
145
  path.unshift('Direct cases') unless path.size > 1
145
146
 
@@ -162,16 +163,26 @@ class TestrailExport < RSpec::Core::Formatters::BaseTextFormatter
162
163
 
163
164
  end
164
165
 
165
- def update_test_run(suite)
166
- run_id = @client.create_run(suite.content, @start_time_str)['id']
166
+ def update_test_run(suite, run_name)
167
+ run_id = @client.create_run(suite.content, run_name)['id']
167
168
  results = suite.each_leaf.map do |test|
168
169
  test_result = test.content[:result].execution_result
169
170
  run_time_seconds = test_result.run_time.round(0)
171
+ infos = { elapsed: (run_time_seconds == 0) ? nil : "#{run_time_seconds}s",
172
+ version: nil
173
+ }
174
+ infos[:comment] = case test_result.status
175
+ when :failed
176
+ [test_result.exception.message, test_result.exception.backtrace].join("\n")
177
+ when :pending
178
+ test_result.pending_message
179
+ else
180
+ nil
181
+ end
170
182
  {
171
183
  case_id: test.content[:case]['id'],
172
- status_id: Testrail::STATUS[test_result.status],
173
- elapsed: (run_time_seconds == 0) ? nil : "#{run_time_seconds}s"
174
- }
184
+ status_id: Testrail::STATUS[test_result.status]
185
+ }.merge(infos.delete_if { |_,v| v.nil? })
175
186
  end
176
187
  @client.add_results_for_cases(run_id, results)
177
188
  end
@@ -180,4 +191,4 @@ class TestrailExport < RSpec::Core::Formatters::BaseTextFormatter
180
191
  # make it a bit freezed
181
192
  Time.at((Time.now.to_i.to_s[0..7] + "00").to_i).strftime('%d %b %Y %R %Z')
182
193
  end
183
- end
194
+ end
@@ -48,11 +48,12 @@ module Testrail
48
48
  @projects ||= @client.send_get('get_projects')
49
49
  end
50
50
 
51
- def add_project(project_name)
51
+ def add_project(project_name, suite_mode=1)
52
52
  @projects = nil # invalidate cached stuff
53
- @client.send_post('add_project', {name: project_name,
54
- announcement: AUTOMATED_DESCRIPTION,
55
- show_anouncement: true})
53
+ @client.send_post('add_project', { name: project_name,
54
+ announcement: AUTOMATED_DESCRIPTION,
55
+ show_anouncement: true,
56
+ suite_mode: suite_mode })
56
57
  end
57
58
 
58
59
  def get_project(project_id)
@@ -136,7 +137,11 @@ module Testrail
136
137
  # ----------------------------------------------------> runs <------------------------------------------------------
137
138
 
138
139
  def create_run(suite, prefix=nil)
139
- @client.send_post("add_run/#{suite['project_id']}", { suite_id: suite['id'], name: "#{prefix || nice_time_now} - #{suite['name']}", description: 'describe it somehow'})
140
+ trailer = suite['name'] == 'Master' ? nil : suite['name']
141
+ run_name = [prefix || nice_time_now, trailer].compact.join(' - ')
142
+ @client.send_post("add_run/#{suite['project_id']}", { suite_id: suite['id'],
143
+ name: run_name,
144
+ description: 'Automated tests execution'})
140
145
  end
141
146
 
142
147
  def add_results_for_cases(run_id, results)
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "testrail_rspec"
7
7
 
8
- spec.version = '0.0.6'
8
+ spec.version = '0.0.7'
9
9
 
10
10
  spec.authors = ["Michal Kubik"]
11
11
  spec.email = ["michal.kubik@boost.no"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testrail_rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Kubik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2014-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.4.1
105
+ rubygems_version: 2.4.2
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: RSpec exporter formatter - pushes test run results to TestRail instance.