awetestlib 0.1.30-x86-mingw32 → 1.2.4-x86-mingw32
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 +7 -0
- data/README.md +101 -41
- data/awetestlib.gemspec +36 -47
- data/awetestlib_osx.gemspec +24 -18
- data/awetestlib_windows.gemspec +46 -0
- data/bin/awetestlib +130 -111
- data/bin/awetestlib-driver-setup.rb +0 -2
- data/bin/awetestlib-helpers.rb +43 -30
- data/lib/awetestlib.rb +196 -20
- data/lib/awetestlib/command_line.rb +44 -0
- data/lib/awetestlib/html_report.rb +57 -50
- data/lib/awetestlib/logging.rb +242 -171
- data/lib/awetestlib/regression/awetest_dsl.rb +4240 -0
- data/lib/awetestlib/regression/browser.rb +514 -397
- data/lib/awetestlib/regression/date_and_time.rb +280 -0
- data/lib/awetestlib/regression/drag_and_drop.rb +24 -0
- data/lib/awetestlib/regression/find.rb +70 -43
- data/lib/awetestlib/regression/legacy.rb +1 -1
- data/lib/awetestlib/regression/mobile.rb +293 -0
- data/lib/awetestlib/regression/reporting.rb +298 -0
- data/lib/awetestlib/regression/runner.rb +156 -200
- data/lib/awetestlib/regression/tables.rb +117 -7
- data/lib/awetestlib/regression/test_data.rb +354 -0
- data/lib/awetestlib/regression/user_input.rb +179 -93
- data/lib/awetestlib/regression/utilities.rb +755 -286
- data/lib/awetestlib/regression/validations.rb +325 -115
- data/lib/awetestlib/regression/waits.rb +60 -133
- data/lib/awetestlib/runner.rb +5 -2
- data/lib/version.rb +11 -2
- data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +109 -49
- data/setup_samples/sample_mobile_app/features/support/env.rb +1 -1
- data/test/google_search2.rb +7 -6
- data/test/popup_child_0.rb +13 -0
- data/test/popup_child_1.rb +33 -0
- data/test/watir_no_require.rb +13 -0
- data/test/watir_with_require.rb +16 -0
- data/test/zoho_exercise.rb +8 -8
- metadata +216 -303
- data/AwetestLib Instructions.rtf +0 -0
- data/awetestlib.windows.gemspec +0 -42
- data/lib/patches/README +0 -2
- data/lib/patches/firewatir.rb +0 -106
- data/lib/patches/watir.rb +0 -175
@@ -311,7 +311,7 @@ module Awetestlib
|
|
311
311
|
# @param (see #click_button_by_id)
|
312
312
|
# @return (see #click_button_by_id)
|
313
313
|
def click_img_by_xpath_and_name(browser, what, desc = '')
|
314
|
-
click(browser, :image, :xpath, "//a[@
|
314
|
+
click(browser, :image, :xpath, "//a[@name = '#{what}']", desc)
|
315
315
|
end
|
316
316
|
|
317
317
|
alias click_img_by_xpath click_img_by_xpath_and_name
|
@@ -0,0 +1,293 @@
|
|
1
|
+
module Awetestlib
|
2
|
+
|
3
|
+
module Regression
|
4
|
+
|
5
|
+
module Mobile
|
6
|
+
|
7
|
+
def open_mobile_browser
|
8
|
+
|
9
|
+
mark_test_level(": #{self.device_type.titleize}")
|
10
|
+
|
11
|
+
if Dir.pwd =~ /shamisen/i
|
12
|
+
subdir = 'awetest_report'
|
13
|
+
sleep1 = 30
|
14
|
+
sleep2 = 90
|
15
|
+
server_url = "http://127.0.0.1:4723/wd/hub"
|
16
|
+
# server_url = 'http://0.0.0.0:4723/wd/hub'
|
17
|
+
else
|
18
|
+
subdir = 'log'
|
19
|
+
sleep1 = 10
|
20
|
+
sleep2 = 10
|
21
|
+
server_url = "http://127.0.0.1:4723/wd/hub"
|
22
|
+
end
|
23
|
+
|
24
|
+
debug_to_log(with_caller("$debug => #{$debug}, $DEBUG => #{$DEBUG}"))
|
25
|
+
log_level = $debug ? 'debug:debug' : 'debug:debug' #'warn:debug'
|
26
|
+
debug_to_log(with_caller("#{Dir.pwd.chomp}"))
|
27
|
+
|
28
|
+
log_file = File.join(Dir.pwd.chomp, subdir, "#{File.basename(__FILE__, '.rb')}_appium_lib_#{Time.now.strftime("%Y%m%d%H%M%S")}.log")
|
29
|
+
command = "start \"appium server\" appium --log-timestamp --log-level #{log_level} -g #{log_file} &"
|
30
|
+
debug_to_log(command)
|
31
|
+
appium = IO.popen(command, :err => :out)
|
32
|
+
@appium_pid = appium.pid
|
33
|
+
debug_to_log(with_caller("Appium PID: #{@appium_pid}"))
|
34
|
+
|
35
|
+
debug_to_log(with_caller("nodejs version: #{`node --version`.chomp}"))
|
36
|
+
|
37
|
+
sleep_for(sleep1)
|
38
|
+
|
39
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
40
|
+
client.timeout = 300
|
41
|
+
desired_caps = set_mobile_capabilities(self.device_id, self.device_type, self.sdk, self.emulator, client, server_url)
|
42
|
+
|
43
|
+
debug_to_log(desired_caps.to_yaml)
|
44
|
+
|
45
|
+
debug_to_log(with_caller('Instantiating Appium Driver'))
|
46
|
+
Appium::Driver.new(desired_caps)
|
47
|
+
debug_to_log(with_caller('Starting Appium Driver'))
|
48
|
+
$driver.start_driver
|
49
|
+
|
50
|
+
sleep_for(sleep2)
|
51
|
+
|
52
|
+
debug_to_log(with_caller('Getting Watir Browser from driver...'))
|
53
|
+
browser = Watir::Browser.new($driver.driver)
|
54
|
+
|
55
|
+
debug_to_log(with_caller('Returning browser'))
|
56
|
+
|
57
|
+
browser
|
58
|
+
rescue
|
59
|
+
failed_to_log(unable_to)
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_mobile_capabilities(device_id, device_type, sdk, emulator, http_client, server_url = "http://127.0.0.1:4723/wd/hub")
|
63
|
+
mark_test_level
|
64
|
+
|
65
|
+
case device_type
|
66
|
+
|
67
|
+
when /android device/i
|
68
|
+
desired_caps = {
|
69
|
+
:caps => {
|
70
|
+
:newCommandTimeout => 600,
|
71
|
+
:androidDeviceReadyTimeout => 420,
|
72
|
+
:avdLaunchTimeout => 240000,
|
73
|
+
:avdReadyTimeout => 240000,
|
74
|
+
:deviceName => "Android Device",
|
75
|
+
:automationName => "Appium",
|
76
|
+
:platformName => "Android",
|
77
|
+
:browserName => "Chrome",
|
78
|
+
:platformVersion => sdk,
|
79
|
+
'app' => "chrome",
|
80
|
+
# 'appPackage' => "com.android.chrome",
|
81
|
+
:udid => device_id,
|
82
|
+
:http_client => http_client,
|
83
|
+
:chromeOptions => { "args" => ['--ignore-certificate-errors', '--verbose'] } #ignore-certificate-errors=true homepage=about:blank test_type=true' }
|
84
|
+
},
|
85
|
+
:appium_lib => {
|
86
|
+
:server_url => server_url
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
when /android emulator/i
|
91
|
+
|
92
|
+
# NOTE: avd cannot start from snapshot?.
|
93
|
+
|
94
|
+
desired_caps = {
|
95
|
+
:caps => {
|
96
|
+
:newCommandTimeout => 1200,
|
97
|
+
:androidDeviceReadyTimeout => 420,
|
98
|
+
:avdLaunchTimeout => 240000,
|
99
|
+
:avdReadyTimeout => 240000,
|
100
|
+
:debug => true,
|
101
|
+
:deviceName => "Android Emulator",
|
102
|
+
:platformName => "Android",
|
103
|
+
:avd => emulator,
|
104
|
+
:browserName => "Browser",
|
105
|
+
:avdArgs => '-no-audio -http-proxy 151.151.15.250:8080 -dns-server 10.27.206.11:55,10.27.206.101:55,10.91.218.197:55',
|
106
|
+
:http_client => http_client,
|
107
|
+
:chromeOptions => { 'args' => ['--ignore-certificate-errors', '--verbose'] }
|
108
|
+
},
|
109
|
+
:appium_lib => {
|
110
|
+
:server_url => server_url
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
when /ios device/i
|
115
|
+
desired_caps = {
|
116
|
+
'platformVersion' => sdk,
|
117
|
+
'deviceName' => "My_device",
|
118
|
+
'platformName' => "iOS",
|
119
|
+
'browserName' => 'Safari',
|
120
|
+
'udid' => device_id }
|
121
|
+
|
122
|
+
when /ios simulator/i
|
123
|
+
desired_caps = {
|
124
|
+
'deviceName' => device_type,
|
125
|
+
'platformVersion' => sdk,
|
126
|
+
'browserName' => 'Safari',
|
127
|
+
'platformName' => "iOS" }
|
128
|
+
else
|
129
|
+
raise "Unrecognized mobile device type: '#{device_type}'"
|
130
|
+
end
|
131
|
+
|
132
|
+
debug_to_log(with_caller("\n#{desired_caps.to_yaml}"))
|
133
|
+
|
134
|
+
desired_caps
|
135
|
+
rescue
|
136
|
+
failed_to_log(unable_to)
|
137
|
+
end
|
138
|
+
|
139
|
+
def parse_environment_node_for_mobile
|
140
|
+
|
141
|
+
if self.environment_nodename =~ /;/
|
142
|
+
entries = {}
|
143
|
+
self.environment['input_nodename'] = self.environment_nodename
|
144
|
+
unless self.environment_nodename =~ /^W:/
|
145
|
+
self.environment_nodename = "W:#{self.environment_nodename}"
|
146
|
+
end
|
147
|
+
parms = self.environment_nodename.split(';')
|
148
|
+
parms.each do |p|
|
149
|
+
key, vlu = p.split(':')
|
150
|
+
entries[key] = vlu
|
151
|
+
end
|
152
|
+
|
153
|
+
entries.each do |key, vlu|
|
154
|
+
case key
|
155
|
+
when 'W'
|
156
|
+
self.environment_nodename = vlu
|
157
|
+
self.options[:environment_nodename] = vlu
|
158
|
+
self.environment['nodename'] = vlu
|
159
|
+
when 'I'
|
160
|
+
self.device_id = vlu
|
161
|
+
self.options[:device_id] = vlu
|
162
|
+
when 'K'
|
163
|
+
self.sdk = vlu
|
164
|
+
self.options[:sdk] = vlu
|
165
|
+
when 'T'
|
166
|
+
self.device_type = vlu
|
167
|
+
self.options[:device_type] = vlu
|
168
|
+
when 'E'
|
169
|
+
self.emulator = vlu
|
170
|
+
self.options[:emulator] = vlu
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
rescue
|
175
|
+
failed_to_log(unable_to)
|
176
|
+
end
|
177
|
+
|
178
|
+
def clean_up_android_temp
|
179
|
+
|
180
|
+
debug_to_log 'Here we will clean up emulator TMP files...'
|
181
|
+
user = Etc::getlogin
|
182
|
+
# debug_to_log user
|
183
|
+
android_temp_path = 'C:\\Users\\'+user+'\\AppData\\Local\\Temp\\AndroidEmulator'
|
184
|
+
debug_to_log android_temp_path
|
185
|
+
if Dir.exists?(android_temp_path)
|
186
|
+
dir = Dir.new(android_temp_path)
|
187
|
+
dir.each do |file|
|
188
|
+
debug_to_log file if file =~ /^TMP.+\.tmp/
|
189
|
+
end
|
190
|
+
tmp_ptrn = '\\TMP*.tmp'
|
191
|
+
dir_cmd = "dir #{android_temp_path}#{tmp_ptrn} 2>&1"
|
192
|
+
del_cmd = "del #{android_temp_path}#{tmp_ptrn} 2>&1"
|
193
|
+
debug_to_log "#{__LINE__}: #{dir_cmd}"
|
194
|
+
dir_out = `#{dir_cmd}`
|
195
|
+
unless dir_out =~ /file not found/i
|
196
|
+
debug_to_log "#{__LINE__}: #{del_cmd}"
|
197
|
+
debug_to_log `#{del_cmd}`.chomp
|
198
|
+
if `#{dir_cmd}` =~ /file not found/i
|
199
|
+
debug_to_log 'Emulator TMP files deleted successfully'
|
200
|
+
end
|
201
|
+
end
|
202
|
+
else
|
203
|
+
debug_to_log("#{android_temp_path} not found")
|
204
|
+
end
|
205
|
+
|
206
|
+
rescue
|
207
|
+
failed_to_log(unable_to)
|
208
|
+
end
|
209
|
+
|
210
|
+
def end_android_processes
|
211
|
+
|
212
|
+
processes = ['node.exe', 'emulator-arm.exe', 'emulator-x86.exe', 'adb.exe', 'chromedriver.exe', 'cmd.exe']
|
213
|
+
tasks = get_process_list
|
214
|
+
targets = []
|
215
|
+
|
216
|
+
if USING_OSX
|
217
|
+
kill_cmd = 'kill -9 @@@@@'
|
218
|
+
else
|
219
|
+
kill_cmd = 'taskkill /f /pid @@@@@'
|
220
|
+
end
|
221
|
+
|
222
|
+
processes.each do |image_name|
|
223
|
+
if image_name == 'cmd.exe'
|
224
|
+
hit = tasks.detect { |t| t[:window_title] =~ /^appium server/i }
|
225
|
+
else
|
226
|
+
hit = tasks.detect { |t| t[:image_name] =~ /^#{image_name}/i }
|
227
|
+
end
|
228
|
+
|
229
|
+
if hit and hit.length > 0
|
230
|
+
targets << hit
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
['node.exe', 'emulator', 'cmd.exe', 'adb.exe', 'chromedriver'].each do |process|
|
235
|
+
hit = targets.detect { |t| t[:image_name] =~ /^#{process}/i }
|
236
|
+
if hit and hit.length > 0
|
237
|
+
pid = hit[:pid]
|
238
|
+
name = hit[:image_name]
|
239
|
+
title = hit[:window_title]
|
240
|
+
cmd = kill_cmd.sub('@@@@@', pid)
|
241
|
+
debug_to_log("[#{cmd}] #{name} #{title}")
|
242
|
+
kill_io = IO.popen(cmd, :err => :out)
|
243
|
+
debug_to_log(kill_io.read.chomp)
|
244
|
+
kill_io.close
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
rescue
|
249
|
+
failed_to_log(unable_to)
|
250
|
+
end
|
251
|
+
|
252
|
+
def get_process_list
|
253
|
+
|
254
|
+
if USING_OSX
|
255
|
+
cmd = "ps axo comm,pid,sess,fname"
|
256
|
+
else
|
257
|
+
cmd = 'tasklist /v -fo csv 2>&1'
|
258
|
+
end
|
259
|
+
|
260
|
+
debug_to_log(cmd)
|
261
|
+
raw = `#{cmd}`
|
262
|
+
list = raw.force_encoding(Encoding::UTF_8)
|
263
|
+
# debug_to_log(list)
|
264
|
+
if list =~ /No tasks are running which match the specified criteria/i
|
265
|
+
tasks = nil
|
266
|
+
else
|
267
|
+
begin
|
268
|
+
csv = CSV.new(list, :headers => true, :header_converters => :symbol)
|
269
|
+
# debug_to_log(with_caller(__LINE__, "\n", "#{csv}"))
|
270
|
+
rescue => e
|
271
|
+
raise e
|
272
|
+
end
|
273
|
+
begin
|
274
|
+
arr = csv.to_a
|
275
|
+
# debug_to_log(with_caller(__LINE__, "\n", "#{arr}"))
|
276
|
+
rescue => e
|
277
|
+
raise e
|
278
|
+
end
|
279
|
+
begin
|
280
|
+
tasks = arr.map { |row| row.to_hash }
|
281
|
+
# debug_to_log(tasks)
|
282
|
+
rescue => e
|
283
|
+
raise e
|
284
|
+
end
|
285
|
+
end
|
286
|
+
tasks
|
287
|
+
rescue
|
288
|
+
failed_to_log(unable_to)
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
@@ -0,0 +1,298 @@
|
|
1
|
+
module Awetestlib
|
2
|
+
|
3
|
+
module Regression
|
4
|
+
|
5
|
+
module Reporting
|
6
|
+
|
7
|
+
def get_caller_line
|
8
|
+
last_caller = get_call_list[0]
|
9
|
+
line = last_caller.split(':', 3)[1]
|
10
|
+
line
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_call_list(depth = 9, dbg = false)
|
14
|
+
my_list = []
|
15
|
+
call_list = Kernel.caller
|
16
|
+
debug_to_log(with_caller(call_list)) if dbg
|
17
|
+
call_list.each_index do |x|
|
18
|
+
my_caller = call_list[x].to_s
|
19
|
+
my_caller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
20
|
+
my_list << "[#{$1.gsub(/eval/, @myName)}] "
|
21
|
+
break if x > depth or my_caller =~ /:in .run.$/
|
22
|
+
end
|
23
|
+
my_list
|
24
|
+
rescue
|
25
|
+
failed_to_log(unable_to)
|
26
|
+
end
|
27
|
+
|
28
|
+
alias get_callers get_call_list
|
29
|
+
|
30
|
+
def get_call_list_new(depth = 15, dbg = $debug)
|
31
|
+
a_list = ['[unknown]']
|
32
|
+
proj_name = File.basename(@library) if @library
|
33
|
+
call_list = Kernel.caller
|
34
|
+
log_message(DEBUG, with_caller(call_list)) if dbg
|
35
|
+
call_list.each_index do |x|
|
36
|
+
a_caller = call_list[x].to_s
|
37
|
+
a_caller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
38
|
+
caller = $1
|
39
|
+
if caller =~ /#{@myName}/
|
40
|
+
a_list << "#{caller.gsub(/\(eval\)/, "(#{@myName})")}"
|
41
|
+
elsif proj_name and caller =~ /#{proj_name}/
|
42
|
+
a_list << "#{caller.gsub(/\(eval\)/, "(#{proj_name})")}" if proj_name
|
43
|
+
elsif @library2 and caller =~ /#{@library2}/
|
44
|
+
a_list << "#{caller.gsub(/\(eval\)/, "(#{@library2})")}" if @library2
|
45
|
+
else
|
46
|
+
a_list << "#{caller}"
|
47
|
+
end
|
48
|
+
next if a_caller =~ /:in .run.$/ and not a_caller.include?(@myName)
|
49
|
+
break if x > depth
|
50
|
+
end
|
51
|
+
a_list
|
52
|
+
rescue
|
53
|
+
failed_to_log(unable_to)
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_debug_list(dbg = false, no_trace = false, last_only = false)
|
57
|
+
calls = get_call_array(10)
|
58
|
+
debug_to_log(with_caller("*** #{__LINE__}\n#{calls.to_yaml}\n***")) if dbg
|
59
|
+
arr = []
|
60
|
+
calls.each_index do |ix|
|
61
|
+
if ix > 1 # skip this method and the logging method
|
62
|
+
if filter_call(calls[ix])
|
63
|
+
arr << calls[ix]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
debug_to_log(with_caller("*** #{__LINE__}\n#{arr.to_yaml}\n***")) if dbg
|
68
|
+
if arr.length > 0
|
69
|
+
list = ''
|
70
|
+
arr.reverse.each do |l|
|
71
|
+
if last_only
|
72
|
+
list = l
|
73
|
+
break
|
74
|
+
else
|
75
|
+
list << "=>#{l}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
if no_trace
|
79
|
+
"#{list}"
|
80
|
+
else
|
81
|
+
" [TRACE:#{list}]"
|
82
|
+
end
|
83
|
+
else
|
84
|
+
''
|
85
|
+
end
|
86
|
+
rescue
|
87
|
+
failed_to_log(unable_to)
|
88
|
+
end
|
89
|
+
|
90
|
+
def filter_call(call)
|
91
|
+
modl = call.match(/^(browser|logging|find|runner|tables|user_input|utilities|validations|waits|page_data|legacy|drag_and_drop|awetest)/) || ''
|
92
|
+
meth = call.match(/in .(run|each)/) || ''
|
93
|
+
true unless "#{modl}#{meth}".length > 0
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_test_level(meth = nil)
|
97
|
+
arr = []
|
98
|
+
each_line = 0
|
99
|
+
call_list = Kernel.caller
|
100
|
+
#debug_to_log("#{call_list.to_yaml}")
|
101
|
+
call_list.each_index do |x|
|
102
|
+
myCaller = call_list[x].to_s
|
103
|
+
myCaller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
104
|
+
string = $1
|
105
|
+
unless string =~ /logging\.rb|mark_test_level|mark_test_level|debug_to_report|debug_toreport/
|
106
|
+
if string.length > 0
|
107
|
+
if string =~ /each|each_key/
|
108
|
+
each_line = string.match(/\:(\d+)\:/)[1]
|
109
|
+
elsif string.match(/\:(\d+)\:/)[1] == each_line
|
110
|
+
next
|
111
|
+
else
|
112
|
+
arr << string.gsub(/eval/, @myName)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
break if meth and string.match(/#{meth}/)
|
117
|
+
break if myCaller =~ /:in .run.$|runner\.rb/
|
118
|
+
end
|
119
|
+
#debug_to_log("#{arr.length} #{nice_array(arr)}")
|
120
|
+
[arr.length, arr]
|
121
|
+
end
|
122
|
+
|
123
|
+
# TODO: need to sanitize html for html report
|
124
|
+
def html_to_log(element)
|
125
|
+
debug_to_log("#{element}\n #{element.html}")
|
126
|
+
end
|
127
|
+
|
128
|
+
# @private
|
129
|
+
def parse_caller(caller)
|
130
|
+
call_script, call_line, call_meth = caller.split(':')
|
131
|
+
call_script.gsub!(/\.rb/, '')
|
132
|
+
call_script = call_script.camelize
|
133
|
+
call_meth =~ /in .([\w\d_ ]+)./
|
134
|
+
call_meth = $1
|
135
|
+
if call_meth.match(/((rescue|block|eval)\s*in\s*)/)
|
136
|
+
delete = $1
|
137
|
+
append = $2
|
138
|
+
call_meth.sub!(delete, '')
|
139
|
+
call_meth << " (#{append})"
|
140
|
+
end
|
141
|
+
[call_script, call_line, call_meth]
|
142
|
+
rescue
|
143
|
+
failed_to_log(unable_to)
|
144
|
+
end
|
145
|
+
|
146
|
+
def initialize_reference_regexp
|
147
|
+
unless @reference_regexp.is_a?(Regexp)
|
148
|
+
@reference_template = '(\*\*\*\s+@@@@\s+\*\*\*)'
|
149
|
+
@reference_pattern = @reference_template.sub('@@@@', '([\w\d_\s,-:;\?]+)')
|
150
|
+
@reference_regexp = Regexp.new(@reference_pattern)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# @private
|
155
|
+
def choose_refs(arr, *indices)
|
156
|
+
refs = ''
|
157
|
+
indices.each do |idx|
|
158
|
+
refs << "*** #{arr[idx]} *** "
|
159
|
+
end
|
160
|
+
refs
|
161
|
+
rescue
|
162
|
+
failed_to_log(unable_to)
|
163
|
+
end
|
164
|
+
|
165
|
+
# @private
|
166
|
+
def format_refs(list)
|
167
|
+
refs = ''
|
168
|
+
if list
|
169
|
+
list.split(/,\s*/).each do |ref|
|
170
|
+
refs << format_reference(ref)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
refs
|
174
|
+
end
|
175
|
+
|
176
|
+
# @private
|
177
|
+
def format_reference(ref)
|
178
|
+
"*** #{ref} *** "
|
179
|
+
end
|
180
|
+
|
181
|
+
# @private
|
182
|
+
def unformat_refs(list)
|
183
|
+
refs = ''
|
184
|
+
if list.is_a?(Array)
|
185
|
+
list.each { |ref| refs << unformat_reference(ref) + ' ' }
|
186
|
+
else
|
187
|
+
list.split(/,\s*/).each do |ref|
|
188
|
+
refs << unformat_reference(ref) + ' '
|
189
|
+
end
|
190
|
+
end
|
191
|
+
refs
|
192
|
+
rescue
|
193
|
+
failed_to_log(unable_to)
|
194
|
+
end
|
195
|
+
|
196
|
+
# @private
|
197
|
+
def unformat_ref_arr(arr)
|
198
|
+
refs = []
|
199
|
+
arr.each { |ref| refs << unformat_reference(ref) }
|
200
|
+
refs
|
201
|
+
rescue
|
202
|
+
failed_to_log(unable_to)
|
203
|
+
end
|
204
|
+
|
205
|
+
# @private
|
206
|
+
def unformat_reference(ref)
|
207
|
+
ref.gsub!('***', '').strip
|
208
|
+
rescue
|
209
|
+
failed_to_log(unable_to)
|
210
|
+
end
|
211
|
+
|
212
|
+
# @private
|
213
|
+
def collect_references(*strings)
|
214
|
+
refs = ''
|
215
|
+
strings.each do |strg|
|
216
|
+
refs << " #{format_refs(strg)}" if strg and strg.length > 0
|
217
|
+
end if strings
|
218
|
+
refs
|
219
|
+
end
|
220
|
+
|
221
|
+
# @private
|
222
|
+
def tally_error_references
|
223
|
+
tags_tested = 0
|
224
|
+
tags_hit = 0
|
225
|
+
if @my_error_hits and @my_error_hits.length > 0
|
226
|
+
mark_test_level(">> Failed Defect or Test Case instances:")
|
227
|
+
tags_hit = @my_error_hits.length
|
228
|
+
@my_error_hits.keys.sort.each do |ref|
|
229
|
+
msg = "#{ref} (#{@my_error_hits[ref]})"
|
230
|
+
msg << " -- #{@refs_desc[ref]}" if @refs_desc
|
231
|
+
message_to_report(msg)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
if @my_error_references and @my_error_references.length > 0
|
235
|
+
tags_tested = @my_error_references.length
|
236
|
+
if self.report_all_test_refs
|
237
|
+
mark_test_level(">> All tested Defect or Test Case instances:")
|
238
|
+
@my_error_references.keys.sort.each do |ref|
|
239
|
+
msg = "#{ref} (#{@my_error_references[ref]})"
|
240
|
+
msg << " -- #{@refs_desc[ref]}" if @refs_desc
|
241
|
+
message_to_report(msg)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
message_to_report(">> Fails on tested Defect or Test Case references: #{tags_hit} of #{tags_tested}")
|
245
|
+
else
|
246
|
+
message_to_report(">> No Defect or Test Case references found.")
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
# @private
|
251
|
+
def parse_error_references(message, fail = false)
|
252
|
+
initialize_reference_regexp unless @reference_regexp
|
253
|
+
msg = message.dup
|
254
|
+
while msg.match(@reference_regexp)
|
255
|
+
capture_error_reference($2, fail)
|
256
|
+
msg.sub!($1, '')
|
257
|
+
end
|
258
|
+
rescue
|
259
|
+
failed_to_log(unable_to)
|
260
|
+
end
|
261
|
+
|
262
|
+
# @private
|
263
|
+
def capture_error_reference(ref, fail)
|
264
|
+
if fail
|
265
|
+
@my_error_hits = Hash.new unless @my_error_hits
|
266
|
+
if @my_error_hits[ref]
|
267
|
+
@my_error_hits[ref] += 1
|
268
|
+
else
|
269
|
+
@my_error_hits[ref] = 1
|
270
|
+
end
|
271
|
+
#debug_to_report("#{__method__}: error hits:\n#{@my_error_hits.to_yaml}")
|
272
|
+
end
|
273
|
+
@my_error_references = Hash.new unless @my_error_references
|
274
|
+
if @my_error_references[ref]
|
275
|
+
@my_error_references[ref] += 1
|
276
|
+
else
|
277
|
+
@my_error_references[ref] = 1
|
278
|
+
end
|
279
|
+
rescue
|
280
|
+
failed_to_log(unable_to)
|
281
|
+
end
|
282
|
+
|
283
|
+
def report_results(errors, msg)
|
284
|
+
call_script, call_line, call_meth = parse_caller(get_call_array[1])
|
285
|
+
msg = ">> SUMMARY: #{build_msg("#{call_meth.titleize}:", msg)}"
|
286
|
+
if errors > 0
|
287
|
+
mark_test_level("#{msg} ::FAIL::")
|
288
|
+
else
|
289
|
+
mark_test_level("#{msg} ::Pass::")
|
290
|
+
true
|
291
|
+
end
|
292
|
+
rescue
|
293
|
+
failed_to_log(unable_to)
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|