cukerail 0.6.1 → 0.6.2
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 +26 -27
- data/lib/json_sender.rb +8 -1
- data/lib/tasks/cukerail.rake +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab0e9bf77e8c770d71213f34b24012e7a16c442b
|
4
|
+
data.tar.gz: 9ff864386200a05132d7b256224d283fcb83a844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd003b53a3dd00f96a9fdb39495c9c6d97ea86ad24feace21ebc006c3fd6a15d49c9891ae16c1bf3e0cf5d2a3d7cb8ce6f84ed35f7ad19b5a4ba129ac7a2054c
|
7
|
+
data.tar.gz: 31089ad0838cc34fa3b5fb770af29b5b6f1a2490ae0068b9a648839357ccf96451acb5dfd3c6efcbd129ac1906124c287c703496343260248319b786a44796cd
|
data/lib/cukerail/version.rb
CHANGED
data/lib/cukerail.rb
CHANGED
@@ -102,36 +102,11 @@ module Cukerail
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def send_steps(test_case,id)
|
105
|
-
|
106
|
-
.select{|step| step.is_a?(Cucumber::Core::Ast::Step)}
|
107
|
-
.reject{|step| step.is_a?(Cucumber::Hooks::BeforeHook)}.map do | g_step |
|
108
|
-
str = g_step.send(:keyword)+g_step.send(:name)
|
109
|
-
str += g_step.multiline_arg.raw.map{|l|"\n| #{l.join(' | ')} |"}.join if g_step.multiline_arg.data_table?
|
110
|
-
str
|
111
|
-
end.join("\n")
|
112
|
-
type_ids = [1]
|
113
|
-
type_ids << 7 if test_case.tags.any?{|tag| tag.name =~/manual/}
|
114
|
-
type_ids << 13 if test_case.tags.any?{|tag| tag.name =~/on_hold/}
|
115
|
-
#get the highest precedence type found in the tags. E.g. if it's @on_hold and @manual it selects 13 for on hold
|
116
|
-
type_id = ([13,7,1] & type_ids).first
|
117
|
-
|
118
|
-
data = {'title'=>extract_title(test_case),
|
119
|
-
'type_id'=>type_id,
|
120
|
-
'custom_steps'=>steps_as_string,
|
121
|
-
'refs'=>refs(test_case)
|
122
|
-
}
|
123
|
-
testrail_api_client.send_post("update_case/#{id}",data)
|
105
|
+
testrail_api_client.send_post("update_case/#{id}",test_case_data(test_case))
|
124
106
|
end
|
125
107
|
|
126
108
|
def create_new_case(project_id,suite_id,sub_section_id,test_case)
|
127
|
-
|
128
|
-
steps_as_string = test_case.test_steps.map{|step| step.source.last}.select{|step| step.is_a?(Cucumber::Core::Ast::Step)}.map{|step| "#{step.keyword}#{step.name}"}.join("\n")
|
129
|
-
data = {'title'=>extract_title(test_case),
|
130
|
-
'type_id'=>(is_manual ? 7 : 1 ),
|
131
|
-
'custom_steps'=>steps_as_string,
|
132
|
-
'refs'=>refs(test_case)
|
133
|
-
}
|
134
|
-
testrail_api_client.send_post("add_case/#{sub_section_id || suite_id}", data)
|
109
|
+
testrail_api_client.send_post("add_case/#{sub_section_id || suite_id}",test_case_data(test_case))
|
135
110
|
end
|
136
111
|
|
137
112
|
def send_result(test_case,result,id,testrun)
|
@@ -214,6 +189,30 @@ module Cukerail
|
|
214
189
|
all_tags(test_case).select{|tag| tag.name =~/(?:jira|ref)_/}.map{|ticket| /(?:jira|ref)_(\w+-\d+)$/.match(ticket.name)[1]}.uniq.join(",")
|
215
190
|
end
|
216
191
|
|
192
|
+
def type_id(test_case)
|
193
|
+
type_ids = [1]
|
194
|
+
type_ids << 7 if test_case.tags.any?{|tag| tag.name =~/manual/}
|
195
|
+
type_ids << 13 if test_case.tags.any?{|tag| tag.name =~/on_hold/}
|
196
|
+
#get the highest precedence type found in the tags. E.g. if it's @on_hold and @manual it selects 13 for on hold
|
197
|
+
([13,7,1] & type_ids).first
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_case_data(test_case)
|
201
|
+
steps_as_string = test_case.test_steps.map{|step| step.source.last}
|
202
|
+
.select{|step| step.is_a?(Cucumber::Core::Ast::Step)}
|
203
|
+
.reject{|step| step.is_a?(Cucumber::Hooks::BeforeHook)}.map do | g_step |
|
204
|
+
str = g_step.send(:keyword)+g_step.send(:name)
|
205
|
+
str += g_step.multiline_arg.raw.map{|l|"\n| #{l.join(' | ')} |"}.join if g_step.multiline_arg.data_table?
|
206
|
+
str
|
207
|
+
end.join("\n")
|
208
|
+
|
209
|
+
{'title'=>extract_title(test_case),
|
210
|
+
'type_id'=>type_id(test_case),
|
211
|
+
'custom_steps'=>steps_as_string,
|
212
|
+
'refs'=>refs(test_case)
|
213
|
+
}
|
214
|
+
end
|
215
|
+
|
217
216
|
def update_run(run_id,case_ids)
|
218
217
|
run = get_run(run_id)
|
219
218
|
begin
|
data/lib/json_sender.rb
CHANGED
@@ -29,7 +29,8 @@ module Cukerail
|
|
29
29
|
if found_case
|
30
30
|
result= found_case['id']
|
31
31
|
else
|
32
|
-
|
32
|
+
test_case = create_new_case(scenario,background_steps,project_id,suite_id,sub_section_id)
|
33
|
+
result = test_case ? test_case['id'] : nil
|
33
34
|
end
|
34
35
|
return result
|
35
36
|
end
|
@@ -58,11 +59,17 @@ module Cukerail
|
|
58
59
|
def create_new_case(scenario,background_steps,project_id,suite_id,sub_section_id)
|
59
60
|
data = prepare_data(scenario,background_steps)
|
60
61
|
testrail_api_client.send_post("add_case/#{sub_section_id || suite_id}", data)
|
62
|
+
rescue StandardError => e
|
63
|
+
puts "#{e.message} in #{get_name(scenario)}"
|
64
|
+
return nil
|
61
65
|
end
|
62
66
|
|
63
67
|
def send_steps(scenario,background_steps,testcase_id)
|
64
68
|
data = prepare_data(scenario,background_steps)
|
65
69
|
testrail_api_client.send_post("update_case/#{testcase_id}",data)
|
70
|
+
rescue StandardError => e
|
71
|
+
puts "#{e.message} in #{get_name(scenario)}"
|
72
|
+
return nil
|
66
73
|
end
|
67
74
|
|
68
75
|
def prepare_data(scenario,background_steps)
|
data/lib/tasks/cukerail.rake
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative '../json_sender'
|
2
|
-
require 'byebug'
|
3
2
|
desc 'load a json results file into a test suite, JSON=filename'
|
4
3
|
task :load_to_suite do
|
5
4
|
raise 'You must have JSON=filename on the command line' unless ENV['JSON']
|
@@ -47,7 +46,8 @@ task :remove_from_test_run do
|
|
47
46
|
testcase_ids << json_sender.get_id(scenario,background_steps,project_id,suite_id,sub_section_id)
|
48
47
|
end
|
49
48
|
end
|
50
|
-
|
49
|
+
# if the title is mroe than 255 characters then Testrail can't create the case, so the id will be nil so we should compact the array
|
50
|
+
json_sender.remove_all_except_these_cases_from_testrun(testcase_ids.compact,ENV['TESTRUN'].to_i)
|
51
51
|
end
|
52
52
|
|
53
53
|
desc "match test run cases to json results file,"
|
@@ -68,5 +68,6 @@ task :remove_from_test_suite do
|
|
68
68
|
testcase_ids << json_sender.get_id(scenario,background_steps,project_id,suite_id,sub_section_id)
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
# if the title is mroe than 255 characters then Testrails can't create the case, so the id will be nil so we should compact the array
|
72
|
+
json_sender.remove_all_except_these_cases_from_suite(testcase_ids.compact,ex_project_id,ex_suite_id)
|
72
73
|
end
|