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 +4 -4
- data/README.md +13 -1
- data/lib/testrail_export.rb +25 -14
- data/lib/testrail_export/client.rb +10 -5
- data/testrail_rspec.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a309a3c8560f79c8d8d14007533e8b2390f7e223
|
4
|
+
data.tar.gz: 43e3a1f3ce7d8239ba75ebe9ee029432b16fbbc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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"
|
data/lib/testrail_export.rb
CHANGED
@@ -20,7 +20,7 @@ class TestrailExport < RSpec::Core::Formatters::BaseTextFormatter
|
|
20
20
|
|
21
21
|
def initialize(output)
|
22
22
|
@options = {}
|
23
|
-
@
|
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| @
|
32
|
-
@
|
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 @
|
106
|
+
if @project.nil?
|
106
107
|
puts "TestRail Exporter [INFO] Creating project: #{@options[:project]}"
|
107
|
-
@
|
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, @
|
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,
|
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
|
-
|
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
|
-
|
55
|
-
|
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
|
-
|
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)
|
data/testrail_rspec.gemspec
CHANGED
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.
|
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-
|
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.
|
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.
|