awetestlib 0.1.23-x86-mingw32 → 0.1.24-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awetestlib/logging.rb +43 -62
- data/lib/awetestlib/regression/legacy.rb +2 -2
- data/lib/awetestlib/regression/runner.rb +1 -1
- data/lib/awetestlib/regression/utilities.rb +48 -3
- data/lib/version.rb +2 -2
- data/test/demo.rb +5 -4
- metadata +4 -4
data/lib/awetestlib/logging.rb
CHANGED
@@ -102,62 +102,44 @@ module Awetestlib
|
|
102
102
|
return { :result => passed, :msg => output_str }
|
103
103
|
end
|
104
104
|
|
105
|
-
# Put status message to the log and output window
|
106
|
-
# TODO: figure out a way to do the leveling automatically based on actual call depth within script (and project library?)
|
107
|
-
# When using to mark test groupings, include
|
108
|
-
# level 'lvl' (numeric literal, 1 through 9, usually 1-4)
|
109
|
-
# indicating test grouping hierarchy:
|
110
|
-
# 0 lowest level test case, a single validation
|
111
|
-
# a.k.a TEST CASE, VALIDATION
|
112
|
-
# not normally used in scripts as it is
|
113
|
-
# implied by method with 'validate' in name
|
114
|
-
# 1 group of closely related level 0 validations
|
115
|
-
# a.k.a TEST GROUP
|
116
|
-
# should never be followed by another level 1
|
117
|
-
# or higher level message without intervening
|
118
|
-
# level 0 validations.
|
119
|
-
# 2 group of closely related level 1 validation sets.
|
120
|
-
# a.k.a TEST SET, SUBMODULE, USE CASE
|
121
|
-
# should never be followed by another level 2
|
122
|
-
# or higher level message without intervening
|
123
|
-
# lower levels.
|
124
|
-
# 3 group of closely related level 2 validation sets.
|
125
|
-
# a.k.a TEST SET, TEST SUITE, MODULE, USE CASE
|
126
|
-
# should never be followed by another level 3
|
127
|
-
# or higher level message without intervening
|
128
|
-
# lower levels.
|
129
|
-
# 4 group of closely related level 3 validation sets.
|
130
|
-
# a.k.a TEST SUITE, APPLICATION UNDER TEST, PLAN, PROJECT
|
131
|
-
# should never be followed by another level 4
|
132
|
-
# or higher level message without intervening
|
133
|
-
# lower levels. Will seldom appear directly in
|
134
|
-
# scripts
|
135
105
|
|
136
106
|
# Write a status message to the log and report indicating location or activity
|
137
|
-
# in the script.
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
107
|
+
# in the script. mark_test_level automatically determines the call hierarchy level
|
108
|
+
# of the calling method within the script and project utility methods. The top level
|
109
|
+
# method of the script is always level 1. The method also prefixes the calling method
|
110
|
+
# name (titleized) to the message to be placed in the log.
|
111
|
+
# @param [String] message The text to place in the log and report after the titleized
|
112
|
+
# calling method name.
|
113
|
+
# @param [Fixnum] lvl '0' forces a message to the report without a specific level
|
114
|
+
# attached. Any other integer is ignored in favor of the calculated level
|
141
115
|
# @param [String] desc Any additional information to add to the message.
|
142
116
|
# @param [Boolean] dbg When set to true adds a trace to the message.
|
143
117
|
# @return [void]
|
144
|
-
def
|
118
|
+
def mark_test_level(message = '', lvl = nil, desc = '', dbg = nil)
|
119
|
+
call_arr = get_call_array()
|
120
|
+
#debug_to_log("#{call_arr.to_yaml}")
|
145
121
|
strg = ''
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
122
|
+
call_script, call_line, call_meth = parse_caller(call_arr[1])
|
123
|
+
if not lvl or lvl > 1
|
124
|
+
lvl, list = get_test_level
|
125
|
+
strg << "#{call_meth.titleize}"
|
126
|
+
end
|
127
|
+
strg << " #{message}" if message.length > 0
|
128
|
+
strg << " (#{desc})" if desc.length > 0
|
129
|
+
strg << " [#{call_line}]"
|
130
|
+
strg << "\n#{list.to_yaml}" if dbg or @debug_calls
|
131
|
+
@report_class.add_to_report(strg, " ", lvl || 1) unless Awetestlib::Runner.nil?
|
132
|
+
log_message(INFO, strg, lvl, nil, 1)
|
151
133
|
rescue
|
152
134
|
failed_to_log("#{__method__}: #{$!}")
|
153
135
|
end
|
154
136
|
|
155
|
-
alias mark_test_level
|
137
|
+
alias mark_testlevel mark_test_level
|
156
138
|
|
157
139
|
# @param [String] message The text to place in the log
|
158
140
|
# @return [void]
|
159
141
|
def info_to_log(message, lnbr = nil)
|
160
|
-
log_message(INFO, message,
|
142
|
+
log_message(INFO, message, 0, lnbr)
|
161
143
|
end
|
162
144
|
|
163
145
|
alias message_tolog info_to_log
|
@@ -188,7 +170,7 @@ module Awetestlib
|
|
188
170
|
message << " \n#{get_debug_list}" if dbg or @debug_calls # and not @debug_calls_fail_only)
|
189
171
|
@my_passed_count += 1 if @my_passed_count
|
190
172
|
parse_error_references(message)
|
191
|
-
@report_class.add_to_report(message, "PASSED")
|
173
|
+
@report_class.add_to_report(message, "PASSED") unless Awetestlib::Runner.nil?
|
192
174
|
log_message(INFO, "#{message}", PASS, lnbr)
|
193
175
|
end
|
194
176
|
|
@@ -204,7 +186,7 @@ module Awetestlib
|
|
204
186
|
message << " \n#{get_debug_list}" if dbg or @debug_calls or @debug_calls_fail_only
|
205
187
|
@my_failed_count += 1 if @my_failed_count
|
206
188
|
parse_error_references(message, true)
|
207
|
-
@report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]", "FAILED")
|
189
|
+
@report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]", "FAILED") unless Awetestlib::Runner.nil?
|
208
190
|
log_message(WARN, "#{message}", FAIL, lnbr)
|
209
191
|
end
|
210
192
|
|
@@ -220,7 +202,7 @@ module Awetestlib
|
|
220
202
|
message << " \n#{get_debug_list}" if dbg or (@debug_calls and not @debug_calls_fail_only)
|
221
203
|
@my_failed_count += 1 if @my_failed_count
|
222
204
|
parse_error_references(message, true)
|
223
|
-
@report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]", "FAILED")
|
205
|
+
@report_class.add_to_report("#{message}" + " [#{get_caller(lnbr)}]", "FAILED") unless Awetestlib::Runner.nil?
|
224
206
|
debug_to_report("#{__method__}:\n#{dump_caller(lnbr)}")
|
225
207
|
log_message(FATAL, "#{message} (#{lnbr})", FAIL, lnbr)
|
226
208
|
end
|
@@ -230,7 +212,7 @@ module Awetestlib
|
|
230
212
|
# @param [String] message The text to place in the log and report
|
231
213
|
# @return [void]
|
232
214
|
def message_to_report(message, dbg = false)
|
233
|
-
mark_testlevel(
|
215
|
+
mark_testlevel(message, 0, '', dbg)
|
234
216
|
end
|
235
217
|
|
236
218
|
# @param [String] message The text to place in the log and report
|
@@ -306,7 +288,7 @@ module Awetestlib
|
|
306
288
|
@start_timestamp = Time.now unless ts
|
307
289
|
utc_ts = @start_timestamp.getutc
|
308
290
|
loc_tm = "#{@start_timestamp.strftime("%H:%M:%S")} #{@start_timestamp.zone}"
|
309
|
-
|
291
|
+
message_to_report(">> Starting #{@myName.titleize} #{utc_ts} (#{loc_tm})")
|
310
292
|
end
|
311
293
|
|
312
294
|
alias start_to_log start_run
|
@@ -314,16 +296,15 @@ module Awetestlib
|
|
314
296
|
# @private
|
315
297
|
# Tally and report duration, validation and failure counts, and end time for the script.
|
316
298
|
# @param [DateTime] ts Time stamp indicating the time the script completed.
|
317
|
-
def finish_run(ts =
|
299
|
+
def finish_run(ts = Time.now)
|
318
300
|
tally_error_references
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
utc_ts =
|
324
|
-
loc_tm = "#{
|
325
|
-
|
326
|
-
|
301
|
+
message_to_report(
|
302
|
+
">> #{@myName.titleize} duration: #{sec2hms(ts - @start_timestamp)}")
|
303
|
+
message_to_report(">> #{@myName.titleize} validations: #{@my_passed_count + @my_failed_count} "+
|
304
|
+
"fail: #{@my_failed_count}]") if @my_passed_count and @my_failed_count
|
305
|
+
utc_ts = ts.getutc
|
306
|
+
loc_tm = "#{ts.strftime("%H:%M:%S")} #{ts.zone}"
|
307
|
+
message_to_report(">> End #{@myName.titleize} #{utc_ts} (#{loc_tm})")
|
327
308
|
end
|
328
309
|
|
329
310
|
alias finish_to_log finish_run
|
@@ -333,22 +314,22 @@ module Awetestlib
|
|
333
314
|
tags_tested = 0
|
334
315
|
tags_hit = 0
|
335
316
|
if @my_error_hits and @my_error_hits.length > 0
|
336
|
-
|
317
|
+
message_to_report(">> Tagged Error Hits:")
|
337
318
|
tags_hit = @my_error_hits.length
|
338
319
|
@my_error_hits.each_key do |ref|
|
339
|
-
|
320
|
+
message_to_report("#{ref} - #{@my_error_hits[ref]}")
|
340
321
|
end
|
341
322
|
end
|
342
323
|
if list_tags
|
343
324
|
if @my_error_references and @my_error_references.length > 0
|
344
|
-
|
325
|
+
message_to_report(">> Error and Test Case Tags:")
|
345
326
|
tags_tested = @my_error_references.length
|
346
327
|
@my_error_references.each_key do |ref|
|
347
|
-
|
328
|
+
message_to_report("#{ref} - #{@my_error_references[ref]}")
|
348
329
|
end
|
349
|
-
|
330
|
+
message_to_report(">> Fails were hit on #{tags_hit} of #{tags_tested} error/test case references")
|
350
331
|
else
|
351
|
-
|
332
|
+
message_to_report(">> No Error or Test Case References found.")
|
352
333
|
end
|
353
334
|
end
|
354
335
|
end
|
@@ -701,8 +701,8 @@ module Awetestlib
|
|
701
701
|
# It's *:value* attribute can also be used when needed by specifying *value*.
|
702
702
|
# @param (see #set_file_field_by_name)
|
703
703
|
# @return (see #click_button_by_id)
|
704
|
-
def
|
705
|
-
|
704
|
+
def clear_checkbox_by_id(browser, strg, value = nil, desc = '')
|
705
|
+
clear_checkbox(browser, :id, strg, desc)
|
706
706
|
end
|
707
707
|
|
708
708
|
# Clear (unset) radio button identified by the attribute specified in *how* with value *what*.
|
@@ -95,7 +95,7 @@ module Awetestlib
|
|
95
95
|
@targetBrowser = browser_to_use(options[:browser], options[:version])
|
96
96
|
@targetVersion = @targetBrowser.version
|
97
97
|
@browserAbbrev = @targetBrowser.abbrev
|
98
|
-
@myRoot = options[:root_path]
|
98
|
+
@myRoot = options[:root_path] || Dir.pwd # NOTE: bug fix pmn 05dec2012
|
99
99
|
@myName = File.basename(options[:script_file]).sub(/\.rb$/, '')
|
100
100
|
|
101
101
|
if options[:output_to_log]
|
@@ -122,7 +122,7 @@ module Awetestlib
|
|
122
122
|
2.upto(workbook.last_column) do |col|
|
123
123
|
scriptName = workbook.cell(1, col)
|
124
124
|
if scriptName == @myName
|
125
|
-
var_col
|
125
|
+
var_col = col
|
126
126
|
script_found_in_data = true
|
127
127
|
break
|
128
128
|
end
|
@@ -145,7 +145,7 @@ module Awetestlib
|
|
145
145
|
password_col = 0
|
146
146
|
url_col = 0
|
147
147
|
name_col = 0
|
148
|
-
login_index
|
148
|
+
login_index = find_sheet_with_name(workbook, 'Login')
|
149
149
|
if login_index and login_index >= 0
|
150
150
|
workbook.default_sheet = workbook.sheets[login_index]
|
151
151
|
|
@@ -153,7 +153,7 @@ module Awetestlib
|
|
153
153
|
a_cell = workbook.cell(1, col)
|
154
154
|
case a_cell
|
155
155
|
when @myName
|
156
|
-
login_col
|
156
|
+
login_col = col
|
157
157
|
script_found_in_login = true
|
158
158
|
break
|
159
159
|
when 'role'
|
@@ -938,6 +938,51 @@ module Awetestlib
|
|
938
938
|
debug_to_log("#{__method__}: #{method} #{$!}")
|
939
939
|
end
|
940
940
|
|
941
|
+
def unable_to(message = '', no_dolbang = false)
|
942
|
+
call_arr = get_call_array()
|
943
|
+
call_script, call_line, call_meth = parse_caller(call_arr[1])
|
944
|
+
strg = "Unable to #{call_meth.titleize}:"
|
945
|
+
strg << " #{message}" if message.length > 0
|
946
|
+
strg << " '#{$!}'" unless no_dolbang
|
947
|
+
strg
|
948
|
+
end
|
949
|
+
|
950
|
+
def parse_caller(caller)
|
951
|
+
call_script, call_line, call_meth = caller.split(':')
|
952
|
+
call_script.gsub!(/\.rb/, '')
|
953
|
+
call_script = call_script.camelize
|
954
|
+
call_meth =~ /in .([\w\d_]+)./
|
955
|
+
call_meth = $1
|
956
|
+
[call_script, call_line, call_meth]
|
957
|
+
end
|
958
|
+
|
959
|
+
def get_test_level
|
960
|
+
arr = []
|
961
|
+
each_line = 0
|
962
|
+
call_list = Kernel.caller
|
963
|
+
#debug_to_log("#{call_list.to_yaml}")
|
964
|
+
call_list.each_index do |x|
|
965
|
+
myCaller = call_list[x].to_s
|
966
|
+
myCaller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
967
|
+
string = $1
|
968
|
+
unless string =~ /logging\.rb|mark_testlevel|mark_test_level|debug_to_report|debug_toreport/
|
969
|
+
if string.length > 0
|
970
|
+
if string =~ /each|each_key/
|
971
|
+
each_line = string.match(/\:(\d+)\:/)[1]
|
972
|
+
elsif string.match(/\:(\d+)\:/)[1] == each_line
|
973
|
+
next
|
974
|
+
else
|
975
|
+
arr << string.gsub(/eval/, @myName)
|
976
|
+
end
|
977
|
+
end
|
978
|
+
end
|
979
|
+
break if myCaller =~ /:in .run.$|runner\.rb/
|
980
|
+
end
|
981
|
+
#debug_to_log("#{arr.length} #{nice_array(arr)}")
|
982
|
+
[arr.length, arr]
|
983
|
+
end
|
984
|
+
|
985
|
+
|
941
986
|
end
|
942
987
|
end
|
943
988
|
end
|
data/lib/version.rb
CHANGED
data/test/demo.rb
CHANGED
@@ -6,7 +6,7 @@ module Demo
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_account_lookup(browser)
|
9
|
-
mark_testlevel(
|
9
|
+
mark_testlevel()
|
10
10
|
browser.image(:title, 'Account Name Lookup').click
|
11
11
|
sleep_for(5)
|
12
12
|
popup = attach_browser_by_url(browser, /Parent/)
|
@@ -22,7 +22,7 @@ module Demo
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def login(browser)
|
25
|
-
mark_testlevel(
|
25
|
+
mark_testlevel()
|
26
26
|
user = "joeklienwatir@gmail.com" #@zohologin.cell(2,2)
|
27
27
|
password = "watir001" #@zohologin.cell(2,3)
|
28
28
|
go_to_url(browser, "https://accounts.zoho.com/login?serviceurl=https://www.zoho.com/&hide_signup=true&css=https://www.zoho.com/css/login.css")
|
@@ -37,11 +37,12 @@ module Demo
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def navigate_to_crm(browser)
|
40
|
-
mark_testlevel(
|
40
|
+
mark_testlevel()
|
41
41
|
click_text(browser, 'CRM')
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_zoho(browser)
|
45
|
+
mark_testlevel()
|
45
46
|
#get_variables("#{@myRoot}/zoho_variables.xls")
|
46
47
|
navigate_to_crm(browser) #In Project Util
|
47
48
|
create_account(browser)
|
@@ -52,7 +53,7 @@ module Demo
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def create_account(browser)
|
55
|
-
mark_testlevel(
|
56
|
+
mark_testlevel()
|
56
57
|
sleep_for(3)
|
57
58
|
click_link(browser, 'Accounts')
|
58
59
|
sleep_for(3)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awetestlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 24
|
10
|
+
version: 0.1.24
|
11
11
|
platform: x86-mingw32
|
12
12
|
authors:
|
13
13
|
- Anthony Woo
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-12-06 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: watir-webdriver
|