taf 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/functions/handlers/base_handler.rb +11 -13
- data/lib/functions/handlers/browser_back.rb +1 -1
- data/lib/functions/handlers/browser_forward.rb +1 -1
- data/lib/functions/handlers/browser_quit.rb +1 -1
- data/lib/functions/handlers/browser_refresh.rb +1 -1
- data/lib/functions/handlers/capture_alert.rb +1 -1
- data/lib/functions/handlers/check_box.rb +4 -7
- data/lib/functions/handlers/check_boxdata.rb +11 -20
- data/lib/functions/handlers/check_browser_title.rb +4 -6
- data/lib/functions/handlers/check_logs.rb +5 -8
- data/lib/functions/handlers/check_screendata.rb +4 -6
- data/lib/functions/handlers/check_url.rb +4 -6
- data/lib/functions/handlers/click_button.rb +5 -8
- data/lib/functions/handlers/execute_system_command.rb +4 -6
- data/lib/functions/handlers/handle_browser_window.rb +5 -7
- data/lib/functions/handlers/ipause.rb +4 -6
- data/lib/functions/handlers/list_all_dropdowns_values.rb +5 -8
- data/lib/functions/handlers/login.rb +10 -8
- data/lib/functions/handlers/open_url.rb +4 -6
- data/lib/functions/handlers/ping_test.rb +4 -6
- data/lib/functions/handlers/radio_button.rb +5 -10
- data/lib/functions/handlers/select_dropdown.rb +6 -10
- data/lib/functions/handlers/send_special_keys.rb +4 -6
- data/lib/functions/handlers/write_box_data.rb +7 -10
- data/lib/main.rb +13 -19
- data/lib/parser/json_parser.rb +15 -8
- data/lib/parser/parser.rb +1 -2
- data/lib/report/junit_report.rb +23 -15
- data/lib/report/report.rb +16 -15
- data/lib/report/report_summary.rb +18 -16
- data/lib/utils/browser.rb +8 -7
- data/lib/utils/cmd_line.rb +11 -3
- data/lib/utils/create_directories.rb +1 -10
- data/lib/utils/screenshot.rb +10 -22
- data/lib/utils/test_engine.rb +17 -18
- data/lib/utils/test_steps.rb +3 -2
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 689534e9c30efe0f07355bb190dc79fc71adc06152a5fda8d79c601e9b1de97d
|
4
|
+
data.tar.gz: 59998580a22f1c1bda658b136aa77a25da75c9b53e5854c9b7b82f8d513c8191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c9a37bee50a842f2b125dcc1ad091219c8b13a87364d71b23e937851faaa88195e2667542c02fbcc87380663d9ecb5dec1c9724179243f025d90251be462d7
|
7
|
+
data.tar.gz: 06ac73be34a9561fe388747ae48f69649d6961393d34e817fd0f34db7356ebb97d4e6436b56d3e4d8c24dbe1930b68778124fe09f3b06897a8f09af3e06ef4db
|
@@ -6,12 +6,19 @@ module TestSteps
|
|
6
6
|
module Handlers
|
7
7
|
# All Login functions function.
|
8
8
|
class Base
|
9
|
+
def initialize(step_attributes)
|
10
|
+
@value = step_attributes[:testvalue]
|
11
|
+
@value2 = step_attributes[:testvalue2]
|
12
|
+
@locate = step_attributes[:locate]
|
13
|
+
@locate2 = step_attributes[:locate2]
|
14
|
+
end
|
15
|
+
|
9
16
|
def self.register(name)
|
10
17
|
TestSteps.handlers[name.to_s] = self
|
11
18
|
end
|
12
19
|
|
13
20
|
def self.perform(*args)
|
14
|
-
new
|
21
|
+
new(*args).perform
|
15
22
|
end
|
16
23
|
|
17
24
|
def open_url_process(url)
|
@@ -23,23 +30,14 @@ module TestSteps
|
|
23
30
|
if Browser.b.title.eql?(b_title)
|
24
31
|
Browser.b.text_field(id: user_elm).wait_until(&:exists?).set user
|
25
32
|
Browser.b.text_field(id: pass_elm).wait_until(&:exists?).set pass
|
26
|
-
|
33
|
+
button = 'Sign in' || 'Log in'
|
34
|
+
Browser.b.button(value: button).wait_until(&:exists?).click
|
27
35
|
sleep 1
|
28
36
|
else
|
29
37
|
MyLog.log.warn("User: #{user} has failed to log in.")
|
30
38
|
end
|
31
39
|
end
|
32
40
|
|
33
|
-
def login_button
|
34
|
-
if Browser.b.button(value: 'Sign in').exist?
|
35
|
-
Browser.b.button(value: 'Sign in').wait_until(&:exists?).click
|
36
|
-
elsif Browser.b.button(value: 'Log in').exist?
|
37
|
-
Browser.b.button(value: 'Log in').wait_until(&:exists?).click
|
38
|
-
else
|
39
|
-
MyLog.log.warn("User: #{user} has failed to log in.")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
41
|
def login_check(b_title_sucess, user)
|
44
42
|
if Browser.b.title.eql?(b_title_sucess)
|
45
43
|
MyLog.log.info("User: #{user} has logged in successful.")
|
@@ -51,7 +49,7 @@ module TestSteps
|
|
51
49
|
end
|
52
50
|
|
53
51
|
def mem_word_check(user, b_title_sucess)
|
54
|
-
if Browser.b.title.eql?('Memorable word
|
52
|
+
if Browser.b.title.eql?('Memorable word')
|
55
53
|
portal_mem_word(user, b_title_sucess)
|
56
54
|
elsif Browser.b.title.eql?(b_title_sucess)
|
57
55
|
MyLog.log.info("User: #{user} has logged in successful.")
|
@@ -8,15 +8,12 @@ module TestSteps
|
|
8
8
|
class CheckBox < Base
|
9
9
|
register :check_box
|
10
10
|
|
11
|
-
def perform
|
12
|
-
checkbox
|
13
|
-
|
14
|
-
|
15
|
-
Browser.b.checkbox("#{locate}": checkbox).wait_until(&:exists?).click
|
16
|
-
MyLog.log.info("Check box: #{checkbox} has been selected")
|
11
|
+
def perform
|
12
|
+
Browser.b.checkbox("#{@locate}": @value).wait_until(&:exists?).click
|
13
|
+
MyLog.log.info("Check box: #{@value} has been selected")
|
17
14
|
true
|
18
15
|
rescue StandardError
|
19
|
-
MyLog.log.warn("Check box: #{
|
16
|
+
MyLog.log.warn("Check box: #{@value} does not exist")
|
20
17
|
false
|
21
18
|
end
|
22
19
|
end
|
@@ -8,35 +8,26 @@ module TestSteps
|
|
8
8
|
class CheckBoxdata < Base
|
9
9
|
register :check_box_data
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
value = step_attributes[:testvalue2]
|
14
|
-
locate = step_attributes[:locate]
|
11
|
+
def perform
|
12
|
+
elms = %i[textarea text_field iframe]
|
15
13
|
|
16
|
-
found_box =
|
17
|
-
Browser.b.
|
18
|
-
|
19
|
-
]
|
14
|
+
found_box = elms.map do |elm|
|
15
|
+
Browser.b.send(elm, "#{@locate}": @value).exists?
|
16
|
+
end.compact
|
20
17
|
|
21
18
|
raise 'Multiple matches' if found_box.select { |i| i }.empty?
|
22
19
|
|
23
20
|
index = found_box.index(true)
|
24
21
|
return unless index
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
(Browser.b.text_field("#{locate}": box).value == value)
|
32
|
-
end
|
33
|
-
MyLog.log.info("Textbox: #{box} has the correct value: #{value}")
|
23
|
+
ele = Browser.b.send(elms[index], "#{@locate}": @value)
|
24
|
+
|
25
|
+
ele.wait_until(&:exists?)
|
26
|
+
(ele.value == @value2)
|
27
|
+
MyLog.log.info("Textbox: #{@value} has correct value: #{value2}")
|
34
28
|
true
|
35
29
|
rescue StandardError
|
36
|
-
MyLog.log.warn("Textbox: #{
|
37
|
-
false
|
38
|
-
rescue StandardError
|
39
|
-
MyLog.log.warn("Textbox: #{box} does not exist")
|
30
|
+
MyLog.log.warn("Textbox: #{@value} does not exist")
|
40
31
|
false
|
41
32
|
end
|
42
33
|
end
|
@@ -8,14 +8,12 @@ module TestSteps
|
|
8
8
|
class CheckTitle < Base
|
9
9
|
register :check_browser_title
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
|
14
|
-
Browser.b.wait_until { Browser.b.title.eql? b_title }
|
15
|
-
MyLog.log.info("Browser title: #{b_title}")
|
11
|
+
def perform
|
12
|
+
Browser.b.wait_until { Browser.b.title.eql? @value }
|
13
|
+
MyLog.log.info("Browser title: #{@value}")
|
16
14
|
true
|
17
15
|
rescue StandardError
|
18
|
-
MyLog.log.warn("Title not found: #{
|
16
|
+
MyLog.log.warn("Title not found: #{@value}")
|
19
17
|
false
|
20
18
|
end
|
21
19
|
end
|
@@ -8,16 +8,13 @@ module TestSteps
|
|
8
8
|
class CheckLogs < Base
|
9
9
|
register :check_log_file
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
blog_result = system 'egrep -i ' + text + ' ' + file + ' > ' + output
|
16
|
-
if blog_result == true
|
17
|
-
MyLog.log.info("Data has matched: #{text} in LogFile: #{file}")
|
11
|
+
def perform
|
12
|
+
result = system 'egrep -i ' + @value + ' ' + @value2 + ' > ' + output
|
13
|
+
if result == true
|
14
|
+
MyLog.log.info("Data has matched: #{@value} in LogFile: #{@value2}")
|
18
15
|
return true
|
19
16
|
else
|
20
|
-
MyLog.log.warn("Problem finding: #{
|
17
|
+
MyLog.log.warn("Problem finding: #{@value} in LogFile: #{@value2}")
|
21
18
|
return false
|
22
19
|
end
|
23
20
|
end
|
@@ -8,14 +8,12 @@ module TestSteps
|
|
8
8
|
class CheckScreendata < Base
|
9
9
|
register :check_screen_data
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
|
14
|
-
Browser.b.wait_until { Browser.b.element.text.include? check_text }
|
15
|
-
MyLog.log.info("Text found: #{check_text}")
|
11
|
+
def perform
|
12
|
+
Browser.b.wait_until { Browser.b.element.text.include? @value }
|
13
|
+
MyLog.log.info("Text found: #{@value}")
|
16
14
|
true
|
17
15
|
rescue StandardError
|
18
|
-
MyLog.log.warn("Text not found: #{
|
16
|
+
MyLog.log.warn("Text not found: #{@value}")
|
19
17
|
false
|
20
18
|
end
|
21
19
|
end
|
@@ -8,14 +8,12 @@ module TestSteps
|
|
8
8
|
class CheckUrl < Base
|
9
9
|
register :check_url
|
10
10
|
|
11
|
-
def perform
|
12
|
-
url
|
13
|
-
|
14
|
-
if Browser.b.url == url
|
15
|
-
MyLog.log.info("URL: #{url} is correct")
|
11
|
+
def perform
|
12
|
+
if Browser.b.url == @value
|
13
|
+
MyLog.log.info("URL: #{@value} is correct")
|
16
14
|
true
|
17
15
|
else
|
18
|
-
MyLog.log.warn("URL: #{
|
16
|
+
MyLog.log.warn("URL: #{@value} is incorrect")
|
19
17
|
false
|
20
18
|
end
|
21
19
|
end
|
@@ -8,14 +8,11 @@ module TestSteps
|
|
8
8
|
class ClickButton < Base
|
9
9
|
register :click_button
|
10
10
|
|
11
|
-
def perform
|
12
|
-
button = step_attributes[:testvalue]
|
13
|
-
locate = step_attributes[:locate]
|
14
|
-
|
11
|
+
def perform
|
15
12
|
elms = %i[button span a div link image h1 h2 h3 h4]
|
16
13
|
|
17
14
|
found_button = elms.map do |elm|
|
18
|
-
Browser.b.send(elm, "#{locate}":
|
15
|
+
Browser.b.send(elm, "#{@locate}": @value).exists?
|
19
16
|
end.compact
|
20
17
|
|
21
18
|
raise 'Multiple matches' if found_button.select { |i| i }.empty?
|
@@ -23,12 +20,12 @@ module TestSteps
|
|
23
20
|
index = found_button.index(true)
|
24
21
|
return unless index
|
25
22
|
|
26
|
-
Browser.b.send(elms[index], "#{locate}":
|
23
|
+
Browser.b.send(elms[index], "#{@locate}": @value)
|
27
24
|
.wait_until(&:exists?).click
|
28
|
-
MyLog.log.info("Button: #{
|
25
|
+
MyLog.log.info("Button: #{@value} has been selected")
|
29
26
|
true
|
30
27
|
rescue StandardError
|
31
|
-
MyLog.log.warn("Button: #{
|
28
|
+
MyLog.log.warn("Button: #{@value} does not exist")
|
32
29
|
false
|
33
30
|
end
|
34
31
|
end
|
@@ -8,15 +8,13 @@ module TestSteps
|
|
8
8
|
class ExecuteSystemCommand < Base
|
9
9
|
register :execute_system_command
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
|
14
|
-
b_result = system syst_cmd
|
11
|
+
def perform
|
12
|
+
b_result = system @value
|
15
13
|
if b_result == true
|
16
|
-
MyLog.log.info("Cmd has been executed sucessfully #{
|
14
|
+
MyLog.log.info("Cmd has been executed sucessfully #{@value}")
|
17
15
|
return true
|
18
16
|
else
|
19
|
-
MyLog.log.warn("Theres a problem executing command #{
|
17
|
+
MyLog.log.warn("Theres a problem executing command #{@value}")
|
20
18
|
return false
|
21
19
|
end
|
22
20
|
end
|
@@ -8,16 +8,14 @@ module TestSteps
|
|
8
8
|
class HandleBrowserWindow < Base
|
9
9
|
register :handle_browser_window
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
|
14
|
-
Browser.b.window(title: text_check.to_s).use
|
11
|
+
def perform
|
12
|
+
Browser.b.window(title: @value.to_s).use
|
15
13
|
sleep 3
|
16
|
-
Browser.b.title.eql?(
|
17
|
-
MyLog.log.info("Window title: #{
|
14
|
+
Browser.b.title.eql?(@value.to_s)
|
15
|
+
MyLog.log.info("Window title: #{@value} is correct")
|
18
16
|
true
|
19
17
|
rescue StandardError
|
20
|
-
MyLog.log.warn("Window not found: #{
|
18
|
+
MyLog.log.warn("Window not found: #{@value}")
|
21
19
|
false
|
22
20
|
end
|
23
21
|
end
|
@@ -8,14 +8,12 @@ module TestSteps
|
|
8
8
|
class Ipause < Base
|
9
9
|
register :ipause
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
|
14
|
-
sleep(wait_time.to_i)
|
15
|
-
MyLog.log.info('Wait completed for seconds: ' + wait_time.to_s)
|
11
|
+
def perform
|
12
|
+
sleep(@value.to_i)
|
13
|
+
MyLog.log.info('Wait completed for seconds: ' + @value.to_s)
|
16
14
|
true
|
17
15
|
rescue StandardError
|
18
|
-
MyLog.log.warn('Wait failed for seconds: ' +
|
16
|
+
MyLog.log.warn('Wait failed for seconds: ' + @value.to_s)
|
19
17
|
false
|
20
18
|
end
|
21
19
|
end
|
@@ -8,17 +8,14 @@ module TestSteps
|
|
8
8
|
class ListAllDropdownValues < Base
|
9
9
|
register :list_all_dropdown_values
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
locate
|
14
|
-
|
15
|
-
Browser.b.element("#{locate}": dropdown).wait_until(&:exists?)
|
16
|
-
Browser.b.select_list("#{locate}": dropdown).options.each do |i|
|
17
|
-
MyLog.log.info("List of dropdown for #{dropdown} are: #{i.text}")
|
11
|
+
def perform
|
12
|
+
Browser.b.element("#{@locate}": @value).wait_until(&:exists?)
|
13
|
+
Browser.b.select_list("#{@locate}": @value).options.each do |i|
|
14
|
+
MyLog.log.info("List of dropdown for #{@value} are: #{i.text}")
|
18
15
|
return true
|
19
16
|
end
|
20
17
|
rescue StandardError
|
21
|
-
MyLog.log.warn("List dropdown: #{
|
18
|
+
MyLog.log.warn("List dropdown: #{@value} does not exist")
|
22
19
|
false
|
23
20
|
end
|
24
21
|
end
|
@@ -8,20 +8,22 @@ module TestSteps
|
|
8
8
|
class Login < Base
|
9
9
|
register :login
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
user = step_attributes[:testvalue2]
|
11
|
+
def perform
|
12
|
+
user = @value2
|
14
13
|
user = ENV[user.to_s] if ENV[user.to_s]
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
login_user(user)
|
16
|
+
rescue StandardError
|
17
|
+
MyLog.log.error "unable to find login: #{@value}"
|
18
|
+
raise LoginTypeFailed
|
19
|
+
end
|
20
|
+
|
21
|
+
def login_user(user)
|
22
|
+
case @value.downcase
|
18
23
|
when 'portal_login'
|
19
24
|
portal_login(user)
|
20
25
|
when 'sso_login'
|
21
26
|
sso_login(user)
|
22
|
-
else
|
23
|
-
MyLog.log.error "unable to find login: #{lc_login_type}"
|
24
|
-
raise LoginTypeFailed
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -8,15 +8,13 @@ module TestSteps
|
|
8
8
|
class OpenUrl < Base
|
9
9
|
register :open_url
|
10
10
|
|
11
|
-
def perform
|
12
|
-
url = step_attributes[:testvalue]
|
13
|
-
|
11
|
+
def perform
|
14
12
|
Browser.open_browser
|
15
13
|
|
16
|
-
url = if ENV[
|
17
|
-
ENV[
|
14
|
+
url = if ENV[@value]
|
15
|
+
ENV[@value.to_s]
|
18
16
|
else
|
19
|
-
|
17
|
+
@value
|
20
18
|
end
|
21
19
|
Browser.b.goto(url)
|
22
20
|
OpenUrl.check_current_url(url)
|
@@ -9,18 +9,16 @@ module TestSteps
|
|
9
9
|
register :ping_test
|
10
10
|
|
11
11
|
# TODO: retry every 'x' until timeout reached.
|
12
|
-
def perform
|
13
|
-
|
14
|
-
|
15
|
-
check = Net::Ping::HTTP.new(url)
|
12
|
+
def perform
|
13
|
+
check = Net::Ping::HTTP.new(@value)
|
16
14
|
|
17
15
|
check.ping?
|
18
16
|
sleep 5
|
19
17
|
if check.ping?
|
20
|
-
MyLog.log.info("pinged: #{
|
18
|
+
MyLog.log.info("pinged: #{@value}")
|
21
19
|
return true
|
22
20
|
else
|
23
|
-
MyLog.log.warn("Failed to ping: #{
|
21
|
+
MyLog.log.warn("Failed to ping: #{@value}")
|
24
22
|
return false
|
25
23
|
end
|
26
24
|
end
|
@@ -8,18 +8,13 @@ module TestSteps
|
|
8
8
|
class RadioButton < Base
|
9
9
|
register :radio_button
|
10
10
|
|
11
|
-
def perform
|
12
|
-
radio
|
13
|
-
|
14
|
-
|
15
|
-
locate2 = step_attributes[:locate2]
|
16
|
-
|
17
|
-
Browser.b.radio("#{locate}": radio).wait_until(&:exists?)
|
18
|
-
Browser.b.radio("#{locate}": radio, "#{locate2}": value2.to_s).set
|
19
|
-
MyLog.log.info("Radio button: #{radio} has been selected")
|
11
|
+
def perform
|
12
|
+
Browser.b.radio("#{@locate}": @value).wait_until(&:exists?)
|
13
|
+
Browser.b.radio("#{@locate}": @value, "#{@locate2}": @value2.to_s).set
|
14
|
+
MyLog.log.info("Radio button: #{@value2} has been selected")
|
20
15
|
true
|
21
16
|
rescue StandardError
|
22
|
-
MyLog.log.warn("Radio button: #{
|
17
|
+
MyLog.log.warn("Radio button: #{@value2} does not exist")
|
23
18
|
false
|
24
19
|
end
|
25
20
|
end
|
@@ -8,19 +8,15 @@ module TestSteps
|
|
8
8
|
class SelectDropdown < Base
|
9
9
|
register :select_dropdown
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
value2 = step_attributes[:testvalue2]
|
14
|
-
locate = step_attributes[:locate]
|
15
|
-
locate2 = step_attributes[:locate2]
|
11
|
+
def perform
|
12
|
+
ele = Browser.b.select_list("#{@locate}": @value)
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
MyLog.log.info("Dropdown item: #{value2} has been selected")
|
14
|
+
ele.wait_until(&:exists?)
|
15
|
+
ele.option("#{@locate2}": @value2.to_s).select
|
16
|
+
MyLog.log.info("Dropdown item: #{@value2} has been selected")
|
21
17
|
true
|
22
18
|
rescue StandardError
|
23
|
-
MyLog.log.warn("Dropdown item: #{value2} has NOT been selected")
|
19
|
+
MyLog.log.warn("Dropdown item: #{@value2} has NOT been selected")
|
24
20
|
false
|
25
21
|
end
|
26
22
|
end
|
@@ -8,15 +8,13 @@ module TestSteps
|
|
8
8
|
class SendSpecialKeys < Base
|
9
9
|
register :send_special_keys
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
|
14
|
-
Browser.b.send_keys :"#{special_key}"
|
11
|
+
def perform
|
12
|
+
Browser.b.send_keys :"#{@value}"
|
15
13
|
sleep 1
|
16
|
-
MyLog.log.info("Browser Sent key: :#{
|
14
|
+
MyLog.log.info("Browser Sent key: :#{@value} successfully")
|
17
15
|
true
|
18
16
|
rescue StandardError
|
19
|
-
MyLog.log.warn("Browser Failed to Send key: :#{
|
17
|
+
MyLog.log.warn("Browser Failed to Send key: :#{@value}")
|
20
18
|
false
|
21
19
|
end
|
22
20
|
end
|
@@ -8,16 +8,13 @@ module TestSteps
|
|
8
8
|
class WriteBoxdata < Base
|
9
9
|
register :write_box_data
|
10
10
|
|
11
|
-
def perform
|
12
|
-
|
13
|
-
|
14
|
-
locate = step_attributes[:locate]
|
15
|
-
txt = ENV[value.to_s] || step_attributes[:testvalue2]
|
16
|
-
|
11
|
+
def perform
|
12
|
+
txt = @value2
|
13
|
+
txt = ENV[txt.to_s] if ENV[txt.to_s]
|
17
14
|
elms = %i[textarea text_field iframe]
|
18
15
|
|
19
16
|
found_box = elms.map do |elm|
|
20
|
-
Browser.b.send(elm, "#{locate}":
|
17
|
+
Browser.b.send(elm, "#{@locate}": @value).exists?
|
21
18
|
end.compact
|
22
19
|
|
23
20
|
raise 'Multiple matches' if found_box.select { |i| i }.empty?
|
@@ -25,12 +22,12 @@ module TestSteps
|
|
25
22
|
index = found_box.index(true)
|
26
23
|
return unless index
|
27
24
|
|
28
|
-
Browser.b.send(elms[index], "#{locate}":
|
25
|
+
Browser.b.send(elms[index], "#{@locate}": @value)
|
29
26
|
.wait_until(&:exists?).send_keys txt
|
30
|
-
MyLog.log.info("Textbox: #{
|
27
|
+
MyLog.log.info("Textbox: #{@value} has correct value: #{txt}")
|
31
28
|
true
|
32
29
|
rescue StandardError
|
33
|
-
MyLog.log.warn("Textbox: #{
|
30
|
+
MyLog.log.warn("Textbox: #{@value} does not exist")
|
34
31
|
false
|
35
32
|
end
|
36
33
|
end
|
data/lib/main.rb
CHANGED
@@ -10,30 +10,24 @@
|
|
10
10
|
module Main
|
11
11
|
require_relative './taf_config.rb'
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
$totalTestPasses = 0
|
19
|
-
$totalTestFailures = 0
|
20
|
-
$totalTestNotrun = 0
|
21
|
-
$previousTestFail = false
|
22
|
-
$currentTestFail = false
|
23
|
-
# parses the cmd line imput into the taf
|
24
|
-
CMDLine.cmdline_input
|
25
|
-
end
|
13
|
+
# parses the cmd line imput into the taf
|
14
|
+
CMDLine.cmdline_input
|
15
|
+
|
16
|
+
# get the overall test suite end time
|
17
|
+
ts_start_time = Report.current_time
|
26
18
|
|
27
19
|
# process the test files to execute the tests
|
28
|
-
TestEngine.process_testfiles
|
20
|
+
total_passes, total_failures, total_skipped = TestEngine.process_testfiles
|
29
21
|
|
30
|
-
# get the overall test end time
|
31
|
-
|
22
|
+
# get the overall test suite end time
|
23
|
+
ts_end_time = Report.current_time
|
32
24
|
|
33
25
|
# output the overall test summary
|
34
|
-
ReportSummary.
|
35
|
-
|
26
|
+
ReportSummary.overall_test_summary(ts_start_time, ts_end_time, total_passes,
|
27
|
+
total_failures, total_skipped)
|
28
|
+
JunitReport.test_summary_junit(ts_start_time, ts_end_time, total_passes,
|
29
|
+
total_failures, total_skipped)
|
36
30
|
|
37
31
|
# Exit status code.
|
38
|
-
Process.exit(
|
32
|
+
Process.exit(total_failures.zero? ? 0 : 1)
|
39
33
|
end
|
data/lib/parser/json_parser.rb
CHANGED
@@ -12,14 +12,22 @@ module JsonParser
|
|
12
12
|
|
13
13
|
def self.parse_test_header_data(parse_json)
|
14
14
|
# get the number of test steps in the file
|
15
|
-
|
15
|
+
number_test_steps = parse_json['steps'].count
|
16
16
|
# get the remaining test data
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
MyLog.log.info "Number of test steps: #{
|
21
|
-
MyLog.log.info "Test Description: #{
|
22
|
-
MyLog.log.info "TestID: #{
|
17
|
+
@test_id = parse_json['testId']
|
18
|
+
@project_id = parse_json['projectId']
|
19
|
+
test_des = parse_json['testDescription']
|
20
|
+
MyLog.log.info "Number of test steps: #{number_test_steps}"
|
21
|
+
MyLog.log.info "Test Description: #{test_des}"
|
22
|
+
MyLog.log.info "TestID: #{@test_id} \n"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.test_id
|
26
|
+
@test_id
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.project_id
|
30
|
+
@project_id
|
23
31
|
end
|
24
32
|
|
25
33
|
# parseTestStepData
|
@@ -31,7 +39,6 @@ module JsonParser
|
|
31
39
|
locate: parse_json['value1'] || 'id',
|
32
40
|
testvalue2: parse_json['value2'],
|
33
41
|
locate2: parse_json['value3'] || 'id',
|
34
|
-
screenShotData: parse_json['screenshot'] == 'yes',
|
35
42
|
skipTestCase: parse_json['skipTestCase'] == 'yes'
|
36
43
|
}
|
37
44
|
|
data/lib/parser/parser.rb
CHANGED
@@ -11,7 +11,7 @@ module Parser
|
|
11
11
|
require_relative '../taf_config.rb'
|
12
12
|
|
13
13
|
def self.test_files
|
14
|
-
@test_files ||= Dir.glob("#{
|
14
|
+
@test_files ||= Dir.glob("#{CMDLine.tests_folder}/*.json").reject do |file|
|
15
15
|
File.basename(file).start_with?('~$')
|
16
16
|
end.sort
|
17
17
|
end
|
@@ -22,7 +22,6 @@ module Parser
|
|
22
22
|
file_type = File.extname(test_file_name)
|
23
23
|
if file_type.casecmp('.json').zero?
|
24
24
|
MyLog.log.info "Processing test file: #{test_file_name}"
|
25
|
-
MyLog.log.info "Browser Type: #{$browserType}"
|
26
25
|
json = File.read(test_file_name)
|
27
26
|
parse_json = JSON.parse(json)
|
28
27
|
|
data/lib/report/junit_report.rb
CHANGED
@@ -12,31 +12,35 @@ module JunitReport
|
|
12
12
|
# holds printable test report summary for all the executed tests
|
13
13
|
@test_step_report_summary2 = []
|
14
14
|
# construct the test suite header for junit
|
15
|
-
def self.test_step_summary_xml(test_file_name, test_file_name_index
|
15
|
+
def self.test_step_summary_xml(test_file_name, test_file_name_index,
|
16
|
+
tc_start, tc_end, metrics)
|
17
|
+
number_test_steps = [metrics.stepFailures, metrics.stepPasses,
|
18
|
+
metrics.stepSkipped].sum
|
16
19
|
@test_step_report_summary2[test_file_name_index] = {
|
17
20
|
'classname' => test_file_name,
|
18
21
|
'name' => test_file_name,
|
19
|
-
'assertions' =>
|
20
|
-
'failures' =>
|
21
|
-
'tests' =>
|
22
|
-
'skipped' =>
|
22
|
+
'assertions' => number_test_steps,
|
23
|
+
'failures' => metrics.stepFailures,
|
24
|
+
'tests' => metrics.stepPasses,
|
25
|
+
'skipped' => metrics.stepSkipped,
|
23
26
|
'time' => TimeDifference.between(
|
24
|
-
|
27
|
+
tc_end, tc_start
|
25
28
|
).in_seconds
|
26
29
|
}
|
27
30
|
end
|
28
31
|
|
29
|
-
def self.test_summary_junit
|
32
|
+
def self.test_summary_junit(ts_start_time, ts_end_time, total_passes,
|
33
|
+
total_failures, total_skipped)
|
30
34
|
# output to XML file format for Junit for CI.
|
31
35
|
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
32
36
|
testsuite_attrs = {
|
33
|
-
'classname' =>
|
34
|
-
'name' =>
|
35
|
-
'tests' =>
|
36
|
-
'failures' =>
|
37
|
-
'timestamp' =>
|
38
|
-
'skipped' =>
|
39
|
-
'time' => TimeDifference.between(
|
37
|
+
'classname' => CMDLine.tests_folder.to_s,
|
38
|
+
'name' => CMDLine.tests_folder.to_s,
|
39
|
+
'tests' => total_passes.to_s,
|
40
|
+
'failures' => total_failures.to_s,
|
41
|
+
'timestamp' => ts_start_time.to_s,
|
42
|
+
'skipped' => total_skipped.to_s,
|
43
|
+
'time' => TimeDifference.between(ts_end_time, ts_start_time)
|
40
44
|
.in_seconds
|
41
45
|
}
|
42
46
|
xml.testsuites(testsuite_attrs) do |testsuites|
|
@@ -58,7 +62,11 @@ module JunitReport
|
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
|
-
|
65
|
+
# the test suite summary is a XML report generated will be called
|
66
|
+
# 'report_uuid.xml'
|
67
|
+
ts_xml_file = "#{$project_iddir}/report_#{SecureRandom.uuid}.xml"
|
68
|
+
|
69
|
+
ts_summary_file_xml = File.open(ts_xml_file, 'w')
|
62
70
|
ts_summary_file_xml.write builder.to_xml
|
63
71
|
ts_summary_file_xml.close
|
64
72
|
end
|
data/lib/report/report.rb
CHANGED
@@ -22,8 +22,8 @@ module Report
|
|
22
22
|
|
23
23
|
step = {
|
24
24
|
'id' => test_step_idx,
|
25
|
-
'classname' => "SuiteID: #{
|
26
|
-
"#{test_desc}",
|
25
|
+
'classname' => "SuiteID: #{JsonParser.test_id}" \
|
26
|
+
" Test Step: #{test_step_idx} #{test_desc}",
|
27
27
|
'name' => test_desc,
|
28
28
|
'file' => test_file_name
|
29
29
|
}
|
@@ -38,20 +38,20 @@ module Report
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# print the Pass / Fail status of a test to the test results file
|
41
|
-
def self.test_pass_fail(pass_fail, test_file_name, test_step_idx)
|
41
|
+
def self.test_pass_fail(pass_fail, test_file_name, test_step_idx, metrics)
|
42
42
|
if pass_fail == true
|
43
|
-
$previousTestFail = $currentTestFail
|
44
43
|
$currentTestFail = false
|
45
|
-
|
44
|
+
metrics.stepPasses += 1
|
46
45
|
MyLog.log.info "Test #{test_step_idx} has Passed ".green
|
47
46
|
elsif pass_fail == false
|
48
|
-
$previousTestFail = $currentTestFail
|
49
47
|
$currentTestFail = true
|
50
|
-
|
48
|
+
metrics.stepFailures += 1
|
51
49
|
MyLog.log.info "Test #{test_step_idx} has FAILED ".red
|
50
|
+
sc_file_name = Screenshot.save_screenshot(test_step_idx)
|
52
51
|
failstep = {
|
53
|
-
'message' => "SuiteID: #{
|
54
|
-
|
52
|
+
'message' => "SuiteID: #{JsonParser.test_id}" \
|
53
|
+
" Test Step: #{test_step_idx} Test has" \
|
54
|
+
" FAILED - Check logs, see Screenshot: #{sc_file_name}",
|
55
55
|
'type' => 'FAILURE',
|
56
56
|
'file' => test_file_name
|
57
57
|
}
|
@@ -65,10 +65,11 @@ module Report
|
|
65
65
|
$failtestStep_xml[test_file_name][test_step_idx] = failstep
|
66
66
|
else
|
67
67
|
$currentTestFail = false
|
68
|
-
|
68
|
+
metrics.stepSkipped += 1
|
69
69
|
MyLog.log.info "Test #{test_step_idx} no checks performed ".blue
|
70
70
|
skipstep = {
|
71
|
-
'message' => "SuiteID: #{
|
71
|
+
'message' => "SuiteID: #{JsonParser.test_id}" \
|
72
|
+
" Test Step: #{test_step_idx} No" \
|
72
73
|
' checks performed - Check logs',
|
73
74
|
'type' => 'SKIPPED',
|
74
75
|
'file' => test_file_name
|
@@ -87,7 +88,7 @@ module Report
|
|
87
88
|
test_duration = TimeDifference.between(
|
88
89
|
test_end_time, @test_start_time
|
89
90
|
).humanize || 0
|
90
|
-
MyLog.log.info "Test step duration: #{test_duration}"
|
91
|
+
MyLog.log.info "Test step duration: #{test_duration} \n"
|
91
92
|
end
|
92
93
|
|
93
94
|
# check if the test failure threshold has been reached for total failures
|
@@ -95,7 +96,7 @@ module Report
|
|
95
96
|
# If a certain number of consecutive tests fail then throw an exception
|
96
97
|
def self.check_failure_threshold(test_file_name)
|
97
98
|
consecutive_fail_threshold = 5
|
98
|
-
if $
|
99
|
+
if $currentTestFail
|
99
100
|
@consecutive_test_fail += 1
|
100
101
|
else
|
101
102
|
@consecutive_test_fail = 0
|
@@ -105,11 +106,11 @@ module Report
|
|
105
106
|
|
106
107
|
# write info to stdout
|
107
108
|
MyLog.log.warn "Terminating the current test file: #{test_file_name} as" \
|
108
|
-
" the test failure threshold (#{
|
109
|
+
" the test failure threshold (#{@consecutive_test_fail}) has been" \
|
109
110
|
' reached.'
|
110
111
|
MyLog.log.warn '...continuing with the next test file (if there is one)'
|
111
112
|
|
112
113
|
raise FailureThresholdExceeded,
|
113
|
-
"#{
|
114
|
+
"test failure threshold (#{@consecutive_test_fail}) has been reached"
|
114
115
|
end
|
115
116
|
end
|
@@ -12,23 +12,24 @@ module ReportSummary
|
|
12
12
|
# holds printable test report summary for all the executed tests
|
13
13
|
@test_step_report_summary = []
|
14
14
|
# output the test results summary for the current test case
|
15
|
-
def self.test_step_summary(test_file_name, test_file_name_index)
|
15
|
+
def self.test_step_summary(test_file_name, test_file_name_index, metrics)
|
16
16
|
@test_step_report_summary[test_file_name_index] = <<~TEXT
|
17
17
|
Test file executed: #{test_file_name}
|
18
|
-
Browser
|
19
|
-
Browser
|
20
|
-
There are: #{
|
21
|
-
There are: #{
|
22
|
-
There are: #{
|
18
|
+
Browser Type: #{CMDLine.browser_type}
|
19
|
+
Browser Version: #{Browser.browser_version}
|
20
|
+
There are: #{metrics.stepPasses} Passes
|
21
|
+
There are: #{metrics.stepFailures} Failures
|
22
|
+
There are: #{metrics.stepSkipped} Skipped Tests \n
|
23
23
|
TEXT
|
24
24
|
end
|
25
25
|
|
26
26
|
# output the overall test results summary
|
27
|
-
def self.
|
27
|
+
def self.overall_test_summary(ts_start_time, ts_end_time, total_passes,
|
28
|
+
total_failures, total_skipped)
|
28
29
|
# output to the console
|
29
30
|
|
30
31
|
MyLog.log.info 'Finished processing all test files ' \
|
31
|
-
"from the following test folder: #{
|
32
|
+
"from the following test folder: #{CMDLine.tests_folder}"
|
32
33
|
MyLog.log.info "Overall Test Summary: \n"
|
33
34
|
@test_step_report_summary.each do |test_step_report_summary|
|
34
35
|
test_step_report_summary.each_line do |line|
|
@@ -37,16 +38,17 @@ module ReportSummary
|
|
37
38
|
end
|
38
39
|
|
39
40
|
duration = TimeDifference.between(
|
40
|
-
|
41
|
+
ts_end_time, ts_start_time
|
41
42
|
).humanize || 0
|
42
43
|
|
43
|
-
MyLog.log.info "Total Tests started at: #{
|
44
|
-
MyLog.log.info "Total Tests finished at: #{
|
44
|
+
MyLog.log.info "Total Tests started at: #{ts_start_time}"
|
45
|
+
MyLog.log.info "Total Tests finished at: #{ts_end_time}"
|
45
46
|
MyLog.log.info "Total Tests duration: #{duration}"
|
46
|
-
MyLog.log.info "Total Tests Passed: #{
|
47
|
-
MyLog.log.info "Total Tests Failed: #{
|
48
|
-
MyLog.log.info "Total Tests Skipped: #{
|
49
|
-
|
50
|
-
|
47
|
+
MyLog.log.info "Total Tests Passed: #{total_passes}".green
|
48
|
+
MyLog.log.info "Total Tests Failed: #{total_failures}".red
|
49
|
+
MyLog.log.info "Total Tests Skipped: #{total_skipped}".blue
|
50
|
+
total_tests = [total_passes, total_failures,
|
51
|
+
total_skipped].sum
|
52
|
+
MyLog.log.info "Total Tests: #{total_tests}\n"
|
51
53
|
end
|
52
54
|
end
|
data/lib/utils/browser.rb
CHANGED
@@ -11,7 +11,7 @@ module Browser
|
|
11
11
|
require_relative '../taf_config.rb'
|
12
12
|
# open_browser function
|
13
13
|
def self.open_browser
|
14
|
-
lc_browser_type =
|
14
|
+
lc_browser_type = CMDLine.browser_type.downcase
|
15
15
|
case lc_browser_type
|
16
16
|
when 'chrome'
|
17
17
|
chrome
|
@@ -38,7 +38,6 @@ module Browser
|
|
38
38
|
@browser = Watir::Browser.new :chrome, switches: %w[
|
39
39
|
--acceptInsecureCerts-true --start-maximized --window-size=1920,1080
|
40
40
|
]
|
41
|
-
browser_version
|
42
41
|
end
|
43
42
|
|
44
43
|
# chrome headless browser details
|
@@ -47,7 +46,6 @@ module Browser
|
|
47
46
|
--start-maximized --disable-gpu --headless --acceptInsecureCerts-true
|
48
47
|
--no-sandbox --window-size=1920,1080
|
49
48
|
]
|
50
|
-
browser_version
|
51
49
|
end
|
52
50
|
|
53
51
|
# firefox browser details
|
@@ -57,7 +55,6 @@ module Browser
|
|
57
55
|
driver = Selenium::WebDriver.for(:firefox, desired_capabilities: caps)
|
58
56
|
@browser = Watir::Browser.new(driver)
|
59
57
|
browser_full_screen
|
60
|
-
browser_version
|
61
58
|
end
|
62
59
|
|
63
60
|
# firefox headless browser details
|
@@ -71,8 +68,6 @@ module Browser
|
|
71
68
|
# makes the browser full screen.
|
72
69
|
@browser.driver.manage.window.resize_to(1920, 1200)
|
73
70
|
@browser.driver.manage.window.move_to(0, 0)
|
74
|
-
browser_version
|
75
|
-
# browser
|
76
71
|
end
|
77
72
|
|
78
73
|
# makes the browser full screen.
|
@@ -90,7 +85,13 @@ module Browser
|
|
90
85
|
|
91
86
|
# Check browser version
|
92
87
|
def self.browser_version
|
93
|
-
|
88
|
+
browser_name = CMDLine.browser_type.downcase
|
89
|
+
case browser_name
|
90
|
+
when 'chrome', 'chrome-headless'
|
91
|
+
@browser.driver.capabilities[:version]
|
92
|
+
when 'firefox', 'firefox-headless'
|
93
|
+
@browser.execute_script('return navigator.userAgent;').split('/')[-1]
|
94
|
+
end
|
94
95
|
rescue StandardError
|
95
96
|
'No Browser version'
|
96
97
|
end
|
data/lib/utils/cmd_line.rb
CHANGED
@@ -36,9 +36,9 @@ module CMDLine
|
|
36
36
|
' chrome-headless, firefox, firefox-headless'
|
37
37
|
) do |b|
|
38
38
|
options[:browser] = b
|
39
|
-
|
39
|
+
@browser_type = options[:browser]
|
40
40
|
unless ['chrome', 'chrome-headless', 'firefox', 'firefox-headless']
|
41
|
-
.include?(
|
41
|
+
.include?(@browser_type)
|
42
42
|
MyLog.log.warn 'A valid Browser has not been supplied as a' \
|
43
43
|
' command-line parameter as expected'
|
44
44
|
Process.exit
|
@@ -47,7 +47,7 @@ module CMDLine
|
|
47
47
|
|
48
48
|
parser.on('-t', '--tests testfolder', 'i.e. tests/') do |t|
|
49
49
|
options[:testfolder] = t
|
50
|
-
|
50
|
+
@tests_folder = options[:testfolder]
|
51
51
|
if Parser.test_files.size.positive?
|
52
52
|
MyLog.log.info "There are: #{Parser.test_files.size}" \
|
53
53
|
' test files to process'
|
@@ -60,4 +60,12 @@ module CMDLine
|
|
60
60
|
end
|
61
61
|
end.parse!
|
62
62
|
end
|
63
|
+
|
64
|
+
def self.browser_type
|
65
|
+
@browser_type
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.tests_folder
|
69
|
+
@tests_folder
|
70
|
+
end
|
63
71
|
end
|
@@ -17,25 +17,16 @@ module CreateDirectories
|
|
17
17
|
#
|
18
18
|
# ------->directory named after the test run ID UUID
|
19
19
|
|
20
|
-
def self.time_now
|
21
|
-
Time.new.strftime('%d-%b-%Y_%H_%M')
|
22
|
-
end
|
23
|
-
|
24
20
|
def self.construct_projectdirs
|
25
21
|
# create top-level directory if it doesn't already exist:
|
26
22
|
# Results/Project_id
|
27
|
-
project_id =
|
23
|
+
project_id = JsonParser.project_id.delete(' ')
|
28
24
|
$project_iddir = File.join('Results', project_id)
|
29
25
|
|
30
26
|
FileUtils.mkdir_p($project_iddir)
|
31
27
|
|
32
28
|
# Generate UUID
|
33
29
|
$run_uuid = SecureRandom.uuid
|
34
|
-
|
35
|
-
# the test suite summary is a XML report generated will be called
|
36
|
-
# 'suite_summary.xml'
|
37
|
-
$TestSuiteSummaryXML = "Results/#{project_id}/#{time_now}" \
|
38
|
-
'_test_result.xml'
|
39
30
|
end
|
40
31
|
|
41
32
|
def self.construct_testspecdirs
|
data/lib/utils/screenshot.rb
CHANGED
@@ -10,30 +10,18 @@
|
|
10
10
|
module Screenshot
|
11
11
|
require_relative '../taf_config.rb'
|
12
12
|
|
13
|
-
# create screenshot filename and save the screenshot if the test has failed
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
time = Time.now.strftime('%H%M')
|
18
|
-
sc_dir = CreateDirectories.construct_testspecdirs
|
13
|
+
# create screenshot filename and save the screenshot if the test has failed.
|
14
|
+
def self.save_screenshot(test_step_idx)
|
15
|
+
time = Time.now.strftime('%H%M')
|
16
|
+
sc_dir = CreateDirectories.construct_testspecdirs
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
"_Test_step-#{test_step_idx}_Failed"\
|
23
|
-
"_#{time}.png"
|
24
|
-
else
|
25
|
-
"#{sc_dir}/Test_ID-#{$testId.delete(' ')}"\
|
26
|
-
"_Test_step-#{test_step_idx}_#{time}.png"
|
27
|
-
end
|
18
|
+
sc_file_name = "#{sc_dir}/Test_ID-#{JsonParser.test_id.delete(' ')}"\
|
19
|
+
"_Test_step-#{test_step_idx}_Failed_#{time}.png"
|
28
20
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
MyLog.log.debug "No screenshot requested \n"
|
34
|
-
end
|
35
|
-
|
36
|
-
# if any issues with saving the screenshot then log a warning
|
21
|
+
# Screenshot capture for websites
|
22
|
+
Browser.b.screenshot.save sc_file_name
|
23
|
+
MyLog.log.info("Screenshot saved to: #{sc_file_name} \n")
|
24
|
+
sc_file_name
|
37
25
|
rescue StandardError => e
|
38
26
|
# construct the error message from custom text and the actual system
|
39
27
|
# error message (converted to a string).
|
data/lib/utils/test_engine.rb
CHANGED
@@ -12,11 +12,15 @@ module TestEngine
|
|
12
12
|
|
13
13
|
# process the test files to execute the tests
|
14
14
|
def self.process_testfiles
|
15
|
-
|
16
|
-
|
15
|
+
total_passes = 0
|
16
|
+
total_failures = 0
|
17
|
+
total_skipped = 0
|
17
18
|
|
18
19
|
# loop through all the available test files to execute the tests
|
19
20
|
Parser.test_files.each_with_index do |test_file_name, test_file_index|
|
21
|
+
metrics = Struct.new(:stepPasses, :stepFailures, :stepSkipped)
|
22
|
+
.new(0, 0, 0)
|
23
|
+
|
20
24
|
begin
|
21
25
|
# read in the test data
|
22
26
|
tests = Parser.read_test_data(test_file_name)
|
@@ -32,9 +36,7 @@ module TestEngine
|
|
32
36
|
CreateDirectories.construct_projectdirs
|
33
37
|
|
34
38
|
# get the test case start time
|
35
|
-
|
36
|
-
# initialise the test end time
|
37
|
-
$test_case_end_time = Report.current_time
|
39
|
+
tc_start = Report.current_time
|
38
40
|
|
39
41
|
begin
|
40
42
|
tests['steps'].each_with_index do |test_step, test_step_idx|
|
@@ -44,10 +46,7 @@ module TestEngine
|
|
44
46
|
|
45
47
|
# process the test step data
|
46
48
|
TestSteps.process_test_steps(test_file_name, test_step_idx,
|
47
|
-
parsed_steps)
|
48
|
-
# see if screenshot required
|
49
|
-
Screenshot.save_screenshot(parsed_steps[:screenShotData],
|
50
|
-
test_step_idx)
|
49
|
+
parsed_steps, metrics)
|
51
50
|
end
|
52
51
|
rescue TafError => e
|
53
52
|
warn e
|
@@ -55,24 +54,24 @@ module TestEngine
|
|
55
54
|
end
|
56
55
|
|
57
56
|
# get the test case end time
|
58
|
-
|
57
|
+
tc_end = Report.current_time
|
59
58
|
|
60
59
|
# output the test results summary for the current test case,
|
61
60
|
# pass in the test file number to save the summary against it's testfile
|
62
|
-
ReportSummary.test_step_summary(test_file_name, test_file_index)
|
63
|
-
JunitReport.test_step_summary_xml(test_file_name, test_file_index
|
61
|
+
ReportSummary.test_step_summary(test_file_name, test_file_index, metrics)
|
62
|
+
JunitReport.test_step_summary_xml(test_file_name, test_file_index,
|
63
|
+
tc_start, tc_end, metrics)
|
64
64
|
|
65
65
|
# close the browser if created
|
66
66
|
Browser.b.quit
|
67
67
|
|
68
68
|
# record total passes and failures and reset the failure counters for
|
69
69
|
# the test steps
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
$testStepPasses = 0
|
74
|
-
$testStepFailures = 0
|
75
|
-
$testStepNotrun = 0
|
70
|
+
total_passes += metrics.stepPasses
|
71
|
+
total_failures += metrics.stepFailures
|
72
|
+
total_skipped += metrics.stepSkipped
|
76
73
|
end
|
74
|
+
|
75
|
+
[total_passes, total_failures, total_skipped]
|
77
76
|
end
|
78
77
|
end
|
data/lib/utils/test_steps.rb
CHANGED
@@ -16,7 +16,8 @@ module TestSteps
|
|
16
16
|
|
17
17
|
# process the test step data by matching the test step functions and
|
18
18
|
# processing the associated data accordingly
|
19
|
-
def self.process_test_steps(test_file_name, test_step_idx, step_attributes
|
19
|
+
def self.process_test_steps(test_file_name, test_step_idx, step_attributes,
|
20
|
+
metrics)
|
20
21
|
# print the test step information
|
21
22
|
Report.print_test_step_header(test_file_name, test_step_idx,
|
22
23
|
step_attributes[:testdesc])
|
@@ -26,7 +27,7 @@ module TestSteps
|
|
26
27
|
|
27
28
|
if handler.respond_to?(:perform)
|
28
29
|
func = handler.perform(step_attributes) if runtest == false
|
29
|
-
Report.test_pass_fail(func, test_file_name, test_step_idx)
|
30
|
+
Report.test_pass_fail(func, test_file_name, test_step_idx, metrics)
|
30
31
|
Report.check_failure_threshold(test_file_name)
|
31
32
|
return true
|
32
33
|
else
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Perrett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|