cukerail 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cukerail/version.rb +1 -1
- data/lib/cukerail.rb +43 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b379455c3a2bfece21f51c89c286f5a27e2814
|
4
|
+
data.tar.gz: 7690535fd04963b629039dde58c9ba47961cc7a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96891be91b5458858837a4d5211e8445f12a9a926b9e3821a0ca73a3dbf611cb99048cf8d0647f7fd97d3a2b9fcb8aad3715158ac428e3ef639274a2c6ccc80c
|
7
|
+
data.tar.gz: bfe3178523c78c2e9bb5f530f6dc9d37ecc9a7249f7027b3450688a46672482f26ae21533cdaabc11371a4753e95eaa1c14df2242d12aa80603b91d98a3d328e
|
data/lib/cukerail/version.rb
CHANGED
data/lib/cukerail.rb
CHANGED
@@ -4,7 +4,6 @@ module Cukerail
|
|
4
4
|
class Sender
|
5
5
|
attr_reader :testrail_api_client,:failed_step
|
6
6
|
def initialize(runtime, io, options)
|
7
|
-
puts 'in initialize'
|
8
7
|
if %w(BASE_URL USER PASSWORD).map{|e| ENV["TESTRAIL_#{e}"]}.any?{|e| e=='' || !e}
|
9
8
|
raise 'You need to setup Testrail environment parameters see https://bbcworldwide.atlassian.net/wiki/display/BAR/Installing+and+Running+Cukerail'
|
10
9
|
end
|
@@ -88,8 +87,8 @@ module Cukerail
|
|
88
87
|
|
89
88
|
def send_steps(test_case,id)
|
90
89
|
steps_as_string = test_case.test_steps.map{|step| step.source.last}
|
91
|
-
|
92
|
-
|
90
|
+
.select{|step| step.is_a?(Cucumber::Core::Ast::Step) && step.respond_to?(:gherkin_statement)}
|
91
|
+
.reject{|step| step.is_a?(Cucumber::Hooks::BeforeHook)}.map do | step |
|
93
92
|
g = step.gherkin_statement
|
94
93
|
str = g.keyword+g.name
|
95
94
|
g.rows.each do | row |
|
@@ -102,7 +101,7 @@ module Cukerail
|
|
102
101
|
'type_id'=>(is_manual ? 7 : 1 ),
|
103
102
|
'custom_steps'=>steps_as_string,
|
104
103
|
'refs'=>defects(test_case)
|
105
|
-
|
104
|
+
}
|
106
105
|
testrail_api_client.send_post("update_case/#{id}",data)
|
107
106
|
end
|
108
107
|
|
@@ -113,7 +112,7 @@ module Cukerail
|
|
113
112
|
'type_id'=>(is_manual ? 7 : 1 ),
|
114
113
|
'custom_steps'=>steps_as_string,
|
115
114
|
'refs'=>defects(test_case)
|
116
|
-
|
115
|
+
}
|
117
116
|
testrail_api_client.send_post("add_case/#{sub_section_id || suite_id}", data)
|
118
117
|
end
|
119
118
|
|
@@ -149,7 +148,12 @@ module Cukerail
|
|
149
148
|
begin
|
150
149
|
testrail_api_client.send_post("add_result_for_case/#{testrun}/#{id}",report_on_result)
|
151
150
|
rescue => e
|
152
|
-
|
151
|
+
if e.message =~ /No \(active\) test found for the run\/case combination/
|
152
|
+
add_case_to_test_run(id,testrun)
|
153
|
+
retry
|
154
|
+
else
|
155
|
+
puts "#{e.message} testrun=#{testrun} test case id=#{id}"
|
156
|
+
end
|
153
157
|
end
|
154
158
|
end
|
155
159
|
|
@@ -164,6 +168,14 @@ module Cukerail
|
|
164
168
|
[requirements_tags,title].compact.join(' ').strip
|
165
169
|
end
|
166
170
|
|
171
|
+
def get_run(run_id)
|
172
|
+
testrail_api_client.send_get("get_run/#{run_id}")
|
173
|
+
end
|
174
|
+
|
175
|
+
def get_tests_in_a_run(run_id)
|
176
|
+
testrail_api_client.send_get("get_tests/#{run_id}")
|
177
|
+
end
|
178
|
+
|
167
179
|
def all_tags(test_case)
|
168
180
|
test_case.tags + test_case.feature.tags
|
169
181
|
end
|
@@ -172,6 +184,31 @@ module Cukerail
|
|
172
184
|
all_tags(test_case).select{|tag| tag.name =~/jira_/}.map{|ticket| /STORE-\d+/.match(ticket.name)[0]}.join(" ")
|
173
185
|
end
|
174
186
|
|
187
|
+
def update_run(testrun,case_ids)
|
188
|
+
begin
|
189
|
+
testrail_api_client.send_post("update_run/#{testrun}",case_ids)
|
190
|
+
rescue => e
|
191
|
+
puts "#{e.message} testrun=#{testrun} test case ids=#{case_ids}"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def remove_case_from_test_run(testcase,testrun)
|
196
|
+
testcase_id = get_id(testcase)
|
197
|
+
run = get_run(testrun)
|
198
|
+
unless run['include_all']
|
199
|
+
case_ids = get_tests_in_a_run(testrun).map{|h| h['case_id']} - [testcase_id]
|
200
|
+
update_run(testrun,{'case_ids'=>case_ids})
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def add_case_to_test_run(testcase_id,testrun)
|
205
|
+
run = get_run(testrun)
|
206
|
+
unless run['include_all']
|
207
|
+
case_ids = get_tests_in_a_run(testrun).map{|h| h['case_id']} + [testcase_id]
|
208
|
+
update_run(testrun,{'case_ids'=>case_ids})
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
175
212
|
end
|
176
213
|
|
177
214
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cukerail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Small
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|