taf 0.1.5 → 0.1.6

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/functions/handlers/base_handler.rb +8 -8
  3. data/lib/functions/handlers/browser_back.rb +2 -2
  4. data/lib/functions/handlers/browser_forward.rb +2 -2
  5. data/lib/functions/handlers/browser_quit.rb +2 -2
  6. data/lib/functions/handlers/browser_refresh.rb +2 -2
  7. data/lib/functions/handlers/capture_alert.rb +2 -2
  8. data/lib/functions/handlers/check_box.rb +2 -2
  9. data/lib/functions/handlers/check_boxdata.rb +3 -3
  10. data/lib/functions/handlers/check_browser_title.rb +2 -2
  11. data/lib/functions/handlers/check_logs.rb +2 -2
  12. data/lib/functions/handlers/check_screendata.rb +2 -2
  13. data/lib/functions/handlers/check_url.rb +2 -2
  14. data/lib/functions/handlers/click_button.rb +2 -2
  15. data/lib/functions/handlers/execute_system_command.rb +2 -2
  16. data/lib/functions/handlers/handle_browser_window.rb +2 -2
  17. data/lib/functions/handlers/insert_value_config.rb +3 -3
  18. data/lib/functions/handlers/ipause.rb +2 -2
  19. data/lib/functions/handlers/list_all_dropdowns_values.rb +2 -2
  20. data/lib/functions/handlers/open_portal_url.rb +2 -2
  21. data/lib/functions/handlers/open_url.rb +2 -2
  22. data/lib/functions/handlers/ping_test.rb +2 -2
  23. data/lib/functions/handlers/radio_button.rb +2 -2
  24. data/lib/functions/handlers/select_dropdown.rb +3 -3
  25. data/lib/functions/handlers/send_special_keys.rb +2 -2
  26. data/lib/functions/handlers/write_box_data.rb +3 -3
  27. data/lib/functions/handlers/write_to_editor.rb +3 -3
  28. data/lib/main.rb +4 -4
  29. data/lib/parser/parser.rb +3 -3
  30. data/lib/parser/xlsx_parser.rb +2 -2
  31. data/lib/report/junit_report.rb +1 -1
  32. data/lib/report/report.rb +10 -57
  33. data/lib/report/report_summary.rb +14 -17
  34. data/lib/taf_config.rb +1 -0
  35. data/lib/utils/browser.rb +4 -4
  36. data/lib/utils/create_directories.rb +2 -14
  37. data/lib/utils/logger.rb +21 -0
  38. data/lib/utils/test_engine.rb +5 -24
  39. data/lib/utils/test_steps.rb +1 -2
  40. data/lib/version.rb +1 -1
  41. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bf4d7c1477f373307a3dd922e833020a20eef9152c03ecf7c5700093f6e0ea2
4
- data.tar.gz: '028efb2643375ac7cff7d03f96a02e08301505ccc9583c7cd1a6c2552054a664'
3
+ metadata.gz: f86ace5ef3a38a6e2dd38706ebe56e20afb50bdf5ec78d6db1f2bd63271340f9
4
+ data.tar.gz: 0e448aaa2850b5209d132fb8e94e0bec7f3fb39716395494d064ed4069c64c17
5
5
  SHA512:
6
- metadata.gz: def47ec8aea263fdfafb0b26130fe9c157f2815f0c6bd069a336b9a9c658f3d1ab7874e784b49adb09f38ffb621fbe1e41461845f501689ba7f78b2ef2504519
7
- data.tar.gz: 19ae836691ad2a6952fac705b0fc87832b3a151b3e0f24451551d74f8f96001c004d4b67248ece9f28c32cbd5ae01ccad63ced97d732e1fbeb93c96007292ba2
6
+ metadata.gz: e08b8accbbf33503870b9478f2175c88f7d12c4f764b481f2520a4853c509c757d2f95a8c9be2ab92e8faff8abe267efb0796950005a2800b3427e955d219686
7
+ data.tar.gz: 5e58ff283dff6a4c88409b550b5fb68f7a857d8c66595cafbacfcde673af4ee939e8cb4db0a91cce2f4abfb6eba2a351b50c82d9fddd7276fc8b4b2729fac11c
@@ -22,7 +22,7 @@ module TestSteps
22
22
  login_button
23
23
  sleep 3
24
24
  else
25
- Report.results.puts("User: #{user} has failed to log in.")
25
+ MyLog.log.warn("User: #{user} has failed to log in.")
26
26
  end
27
27
  end
28
28
 
@@ -32,16 +32,16 @@ module TestSteps
32
32
  elsif Browser.b.button(value: 'Log in').exist?
33
33
  Browser.b.button(value: 'Log in').wait_until.click
34
34
  else
35
- Report.results.puts("User: #{user} has failed to log in.")
35
+ MyLog.log.warn("User: #{user} has failed to log in.")
36
36
  end
37
37
  end
38
38
 
39
39
  def login_check(b_title_sucess, user)
40
40
  if Browser.b.title.eql?(b_title_sucess)
41
- Report.results.puts("User: #{user} has logged in successful.")
41
+ MyLog.log.info("User: #{user} has logged in successful.")
42
42
  true
43
43
  else
44
- Report.results.puts("User: #{user} has failed to log in.")
44
+ MyLog.log.warn("User: #{user} has failed to log in.")
45
45
  false
46
46
  end
47
47
  end
@@ -50,10 +50,10 @@ module TestSteps
50
50
  if Browser.b.title.eql?('Memorable word - UKCloud Portal')
51
51
  portal_mem_word(user, b_title_sucess)
52
52
  elsif Browser.b.title.eql?(b_title_sucess)
53
- Report.results.puts("User: #{user} has logged in successful.")
53
+ MyLog.log.info("User: #{user} has logged in successful.")
54
54
  true
55
55
  else
56
- Report.results.puts("User: #{user} has failed to log in.")
56
+ MyLog.log.warn("User: #{user} has failed to log in.")
57
57
  false
58
58
  end
59
59
  end
@@ -77,10 +77,10 @@ module TestSteps
77
77
 
78
78
  Browser.b.button(value: 'Sign in').wait_until.click
79
79
  if Browser.b.title.eql?(b_title_sucess)
80
- Report.results.puts("User: #{user} has logged in successful.")
80
+ MyLog.log.info("User: #{user} has logged in successful.")
81
81
  return true
82
82
  else
83
- Report.results.puts("User: #{user} has failed to log in.")
83
+ MyLog.log.warn("User: #{user} has failed to log in.")
84
84
  return false
85
85
  end
86
86
  end
@@ -7,10 +7,10 @@ module TestSteps
7
7
 
8
8
  def perform(step_attributes)
9
9
  Browser.b.back
10
- Report.results.puts('Browser navigated back')
10
+ MyLog.log.info('Browser navigated back')
11
11
  true
12
12
  rescue StandardError
13
- Report.results.puts('Browser failed to navigate back')
13
+ MyLog.log.warn('Browser failed to navigate back')
14
14
  false
15
15
  end
16
16
  end
@@ -7,10 +7,10 @@ module TestSteps
7
7
 
8
8
  def perform(step_attributes)
9
9
  Browser.b.forward
10
- Report.results.puts('Browser navigated forward')
10
+ MyLog.log.info('Browser navigated forward')
11
11
  true
12
12
  rescue StandardError
13
- Report.results.puts('Browser failed to navigate forward')
13
+ MyLog.log.warn('Browser failed to navigate forward')
14
14
  false
15
15
  end
16
16
  end
@@ -7,10 +7,10 @@ module TestSteps
7
7
 
8
8
  def perform(step_attributes)
9
9
  Browser.b.quit
10
- Report.results.puts('Browser has closed successfully')
10
+ MyLog.log.info('Browser has closed successfully')
11
11
  true
12
12
  rescue StandardError
13
- Report.results.puts('Browser has failed to close')
13
+ MyLog.log.warn('Browser has failed to close')
14
14
  false
15
15
  end
16
16
  end
@@ -7,10 +7,10 @@ module TestSteps
7
7
 
8
8
  def perform(step_attributes)
9
9
  Browser.b.refresh
10
- Report.results.puts('The Browser has been refreshed')
10
+ MyLog.log.info('The Browser has been refreshed')
11
11
  true
12
12
  rescue StandardError
13
- Report.results.puts('The Browser failed to refresh')
13
+ MyLog.log.warn('The Browser failed to refresh')
14
14
  false
15
15
  end
16
16
  end
@@ -8,10 +8,10 @@ module TestSteps
8
8
  def perform(step_attributes)
9
9
  Browser.b.div(class: 'alert').exist?
10
10
  alertmsg = Browser.b.div(class: 'alert').text
11
- Report.results.puts("Alert shown: #{alertmsg}")
11
+ MyLog.log.info("Alert shown: #{alertmsg}")
12
12
  true
13
13
  rescue StandardError
14
- Report.results.puts('No Alert Found')
14
+ MyLog.log.warn('No Alert Found')
15
15
  false
16
16
  end
17
17
  end
@@ -10,10 +10,10 @@ module TestSteps
10
10
  locate = step_attributes[:locate]
11
11
 
12
12
  Browser.b.checkbox(:"#{locate}" => checkbox).wait_until.click
13
- Report.results.puts("Check box: #{checkbox} has been selected")
13
+ MyLog.log.info("Check box: #{checkbox} has been selected")
14
14
  true
15
15
  rescue StandardError
16
- Report.results.puts("Check box: #{checkbox} does not exist")
16
+ MyLog.log.warn("Check box: #{checkbox} does not exist")
17
17
  false
18
18
  end
19
19
  end
@@ -25,13 +25,13 @@ module TestSteps
25
25
  Browser.b.text_field(:"#{locate}" => box).wait_until
26
26
  (Browser.b.text_field(:"#{locate}" => box).value == value)
27
27
  end
28
- Report.results.puts("Textbox: #{box} has the correct value: #{value}")
28
+ MyLog.log.info("Textbox: #{box} has the correct value: #{value}")
29
29
  true
30
30
  rescue StandardError
31
- Report.results.puts("Textbox: #{box} has the incorrect value: #{value}")
31
+ MyLog.log.warn("Textbox: #{box} has the incorrect value: #{value}")
32
32
  false
33
33
  rescue StandardError
34
- Report.results.puts("Textbox: #{box} does not exist")
34
+ MyLog.log.warn("Textbox: #{box} does not exist")
35
35
  false
36
36
  end
37
37
  end
@@ -10,10 +10,10 @@ module TestSteps
10
10
 
11
11
  sleep 2
12
12
  if Browser.b.title.eql?(text_check)
13
- Report.results.puts("Browser title: #{text_check}")
13
+ MyLog.log.info("Browser title: #{text_check}")
14
14
  return true
15
15
  else
16
- Report.results.puts("Title not found: #{text_check}")
16
+ MyLog.log.warn("Title not found: #{text_check}")
17
17
  return false
18
18
  end
19
19
  end
@@ -11,10 +11,10 @@ module TestSteps
11
11
 
12
12
  blog_result = system 'egrep -i ' + text + ' ' + file + ' > ' + output
13
13
  if blog_result == true
14
- Report.results.puts("Data has matched: #{text} in LogFile: #{file}")
14
+ MyLog.log.info("Data has matched: #{text} in LogFile: #{file}")
15
15
  return true
16
16
  else
17
- Report.results.puts("Problem finding: #{text} in LogFile: #{file}")
17
+ MyLog.log.warn("Problem finding: #{text} in LogFile: #{file}")
18
18
  return false
19
19
  end
20
20
  end
@@ -10,10 +10,10 @@ module TestSteps
10
10
 
11
11
  sleep 5
12
12
  if Browser.b.text.include?(text_check)
13
- Report.results.puts("Found text: #{text_check}")
13
+ MyLog.log.info("Found text: #{text_check}")
14
14
  return true
15
15
  else
16
- Report.results.puts("NOT found text: #{text_check}")
16
+ MyLog.log.warn("NOT found text: #{text_check}")
17
17
  return false
18
18
  end
19
19
  end
@@ -9,10 +9,10 @@ module TestSteps
9
9
  url = step_attributes[:testvalue]
10
10
 
11
11
  if Browser.b.url == url
12
- Report.results.puts("URL: #{url} is correct")
12
+ MyLog.log.info("URL: #{url} is correct")
13
13
  true
14
14
  else
15
- Report.results.puts("URL: #{url} is incorrect")
15
+ MyLog.log.warn("URL: #{url} is incorrect")
16
16
  false
17
17
  end
18
18
  end
@@ -41,10 +41,10 @@ module TestSteps
41
41
  when 9
42
42
  Browser.b.h4(:"#{locate}" => button).wait_until.click
43
43
  end
44
- Report.results.puts("Button: #{button} has been selected")
44
+ MyLog.log.info("Button: #{button} has been selected")
45
45
  true
46
46
  rescue StandardError
47
- Report.results.puts("Button: #{button} does not exist")
47
+ MyLog.log.warn("Button: #{button} does not exist")
48
48
  false
49
49
  end
50
50
  end
@@ -10,10 +10,10 @@ module TestSteps
10
10
 
11
11
  b_result = system syst_cmd
12
12
  if b_result == true
13
- Report.results.puts("Cmd has been executed sucessfully #{syst_cmd}")
13
+ MyLog.log.info("Cmd has been executed sucessfully #{syst_cmd}")
14
14
  return true
15
15
  else
16
- Report.results.puts("Theres a problem executing command #{syst_cmd}")
16
+ MyLog.log.warn("Theres a problem executing command #{syst_cmd}")
17
17
  return false
18
18
  end
19
19
  end
@@ -11,10 +11,10 @@ module TestSteps
11
11
  Browser.b.window(title: text_check.to_s).use
12
12
  sleep 3
13
13
  Browser.b.title.eql?(text_check.to_s)
14
- Report.results.puts("Window title: #{text_check} is correct")
14
+ MyLog.log.info("Window title: #{text_check} is correct")
15
15
  true
16
16
  rescue StandardError
17
- Report.results.puts("Window not found: #{text_check}")
17
+ MyLog.log.warn("Window not found: #{text_check}")
18
18
  false
19
19
  end
20
20
  end
@@ -13,13 +13,13 @@ module TestSteps
13
13
 
14
14
  Browser.b.text_field(:"#{locate}" => box).wait_until.set value
15
15
  (Browser.b.text_field(:"#{locate}" => box).value == value)
16
- Report.results.puts("Textbox: #{box} has correct value: #{value}")
16
+ MyLog.log.info("Textbox: #{box} has correct value: #{value}")
17
17
  true
18
18
  rescue StandardError
19
- Report.results.puts("Textbox: #{box} has the incorrect value: #{value}")
19
+ MyLog.log.warn("Textbox: #{box} has the incorrect value: #{value}")
20
20
  false
21
21
  rescue StandardError
22
- Report.results.puts("Textbox: #{box} does not exist")
22
+ MyLog.log.warn("Textbox: #{box} does not exist")
23
23
  false
24
24
  end
25
25
  end
@@ -9,10 +9,10 @@ module TestSteps
9
9
  wait_time = step_attributes[:testvalue]
10
10
 
11
11
  sleep(wait_time.to_i)
12
- Report.results.puts('Wait completed for seconds: ' + wait_time.to_s)
12
+ MyLog.log.info('Wait completed for seconds: ' + wait_time.to_s)
13
13
  true
14
14
  rescue StandardError
15
- Report.results.puts('Wait failed for seconds: ' + wait_time.to_s)
15
+ MyLog.log.warn('Wait failed for seconds: ' + wait_time.to_s)
16
16
  false
17
17
  end
18
18
  end
@@ -11,11 +11,11 @@ module TestSteps
11
11
 
12
12
  Browser.b.element(:"#{locate}" => dropdown).wait_until
13
13
  Browser.b.select_list(:"#{locate}" => dropdown).options.each do |i|
14
- Report.results.puts("List of dropdown for #{dropdown} are: #{i.text}")
14
+ MyLog.log.info("List of dropdown for #{dropdown} are: #{i.text}")
15
15
  return true
16
16
  end
17
17
  rescue StandardError
18
- Report.results.puts("List dropdown: #{dropdown} does not exist")
18
+ MyLog.log.warn("List dropdown: #{dropdown} does not exist")
19
19
  false
20
20
  end
21
21
  end
@@ -12,10 +12,10 @@ module TestSteps
12
12
  Browser.b.goto(url)
13
13
  url_nme = Browser.b.url
14
14
  if url_nme == url
15
- Report.results.puts("opened URL: #{url}")
15
+ MyLog.log.info("opened URL: #{url}")
16
16
  return true
17
17
  else
18
- Report.results.puts("URL not open: #{url} - opened #{url_nme} instead")
18
+ MyLog.log.warn("URL not open: #{url} - opened #{url_nme} instead")
19
19
  return false
20
20
  end
21
21
  end
@@ -13,10 +13,10 @@ module TestSteps
13
13
  sleep 2
14
14
  url_nme = Browser.b.url
15
15
  if url_nme == url
16
- Report.results.puts("opened URL: #{url}")
16
+ MyLog.log.info("Opened URL: #{url}")
17
17
  return true
18
18
  else
19
- Report.results.puts("URL not open: #{url} - opened #{url_nme} instead")
19
+ MyLog.log.warn("URL not open: #{url} - opened #{url_nme} instead")
20
20
  return false
21
21
  end
22
22
  end
@@ -13,11 +13,11 @@ module TestSteps
13
13
  sleep 5
14
14
  if check.ping? == true
15
15
  # website alive
16
- Report.results.puts("pinged: #{url}")
16
+ MyLog.log.info("pinged: #{url}")
17
17
  return true
18
18
  else
19
19
  # website not responding
20
- Report.results.puts("Failed to ping: #{url}")
20
+ MyLog.log.warn("Failed to ping: #{url}")
21
21
  return false
22
22
  end
23
23
  end
@@ -13,10 +13,10 @@ module TestSteps
13
13
 
14
14
  Browser.b.radio(:"#{locate}" => radio).wait_until
15
15
  Browser.b.radio(:"#{locate}" => radio, :"#{locate2}" => "#{value2}").set
16
- Report.results.puts("Radio button: #{radio} has been selected")
16
+ MyLog.log.info("Radio button: #{radio} has been selected")
17
17
  true
18
18
  rescue StandardError
19
- Report.results.puts("Radio button: #{radio} does not exist")
19
+ MyLog.log.warn("Radio button: #{radio} does not exist")
20
20
  false
21
21
  end
22
22
  end
@@ -13,13 +13,13 @@ module TestSteps
13
13
 
14
14
  Browser.b.select_list(:"#{locate}" => dropdown).wait_until
15
15
  Browser.b.select_list(:"#{locate}" => dropdown).option(:"#{locate2}" => "#{value2}").select
16
- Report.results.puts("Dropdown item: #{value2} has been selected")
16
+ MyLog.log.info("Dropdown item: #{value2} has been selected")
17
17
  true
18
18
  rescue StandardError
19
- Report.results.puts("Dropdown item: #{value2} has NOT been selected")
19
+ MyLog.log.warn("Dropdown item: #{value2} has NOT been selected")
20
20
  false
21
21
  rescue StandardError
22
- Report.results.puts("the dropdown: #{dropdown} does not exist")
22
+ MyLog.log.warn("the dropdown: #{dropdown} does not exist")
23
23
  false
24
24
  end
25
25
  end
@@ -10,10 +10,10 @@ module TestSteps
10
10
 
11
11
  Browser.b.send_keys :"#{special_key}"
12
12
  sleep 1
13
- Report.results.puts("Browser Sent key: :#{special_key} successfully")
13
+ MyLog.log.info("Browser Sent key: :#{special_key} successfully")
14
14
  true
15
15
  rescue StandardError
16
- Report.results.puts("Browser Failed to Send key: :#{special_key}")
16
+ MyLog.log.warn("Browser Failed to Send key: :#{special_key}")
17
17
  false
18
18
  end
19
19
  end
@@ -25,13 +25,13 @@ module TestSteps
25
25
  Browser.b.text_field(:"#{locate}" => box).wait_until.set value
26
26
  (Browser.b.text_field(:"#{locate}" => box).value == value)
27
27
  end
28
- Report.results.puts("Textbox: #{box} has correct value: #{value}")
28
+ MyLog.log.info("Textbox: #{box} has correct value: #{value}")
29
29
  true
30
30
  rescue StandardError
31
- Report.results.puts("Textbox: #{box} has the incorrect value: #{value}")
31
+ MyLog.log.warn("Textbox: #{box} has the incorrect value: #{value}")
32
32
  false
33
33
  rescue StandardError
34
- Report.results.puts("Textbox: #{box} does not exist")
34
+ MyLog.log.warn("Textbox: #{box} does not exist")
35
35
  false
36
36
  end
37
37
  end
@@ -12,13 +12,13 @@ module TestSteps
12
12
 
13
13
  Browser.b.iframe(:"#{locate}" => iframe).wait_until
14
14
  Browser.b.iframe(:"#{locate}" => iframe).send_keys value
15
- Report.results.puts("Editor box: #{iframe} has correct value: #{value}")
15
+ MyLog.log.info("Editor box: #{iframe} has correct value: #{value}")
16
16
  true
17
17
  rescue StandardError
18
- Report.results.puts("Editor box: #{iframe} has wrong value: #{value}")
18
+ MyLog.log.warn("Editor box: #{iframe} has wrong value: #{value}")
19
19
  false
20
20
  rescue StandardError
21
- Report.results.puts("Editor box: #{iframe} does not exist")
21
+ MyLog.log.warn("Editor box: #{iframe} does not exist")
22
22
  false
23
23
  end
24
24
  end
@@ -32,11 +32,11 @@ module Main
32
32
  # Testsuite File and Browser.
33
33
  if ARGV.length < 2
34
34
  $testSuiteFile = ARGV[0]
35
- puts 'Only one argument needed: {TestSuite File}'
35
+ MyLog.log.info 'Only one argument needed: {TestSuite File}'
36
36
  elsif ARGV.length < 3
37
37
  $testSuiteFile = ARGV[0]
38
38
  $browserType = ARGV[1]
39
- puts 'Only 2 arguments needed: {TestSuite File} {Browser}'
39
+ MyLog.log.info 'Only 2 arguments needed: {TestSuite File} {Browser}'
40
40
  else
41
41
  # unable to open file as not supplied as command-line parameter
42
42
  $testSuiteFile = 'unknown'
@@ -50,11 +50,11 @@ module Main
50
50
  # unable to read the test file then handle the error and terminate
51
51
  rescue StandardError => error
52
52
  warn error
53
- $stdout.puts error
53
+ MyLog.log.warn error
54
54
  abort
55
55
  end
56
56
 
57
- puts "There are: #{$numberOfTestSpecs} test files to process \n"
57
+ MyLog.log.info "There are: #{$numberOfTestSpecs} test files to process \n"
58
58
 
59
59
  # process the test files to execute the tests
60
60
  TestEngine.process_testfiles
@@ -14,7 +14,7 @@ module Parser
14
14
  def self.read_test_suite_data
15
15
  # check if the file list exists and is readable
16
16
  if (File.file?($testSuiteFile) & File.readable?($testSuiteFile))
17
- puts "\nProcessing test suite file: #{$testSuiteFile}"
17
+ MyLog.log.info "Processing test suite file: #{$testSuiteFile}"
18
18
  # get the file type
19
19
  fileType = File.extname($testSuiteFile)
20
20
  # extract the test data from the test suite
@@ -60,8 +60,8 @@ module Parser
60
60
  # get the file type
61
61
  fileType = File.extname(testFileName)
62
62
  if (fileType.casecmp(@XlsxFileNameType) == 0)
63
- puts "Processing test file: #{testFileName}"
64
- puts "Browser Type: #{$browserType}"
63
+ MyLog.log.info "Processing test file: #{testFileName}"
64
+ MyLog.log.info "Browser Type: #{$browserType}"
65
65
  $xlsxDoc = RubyXL::Parser.parse(testFileName)
66
66
  XlsxParser.parse_xlxs_test_header_data
67
67
  return 'XLSX'
@@ -52,8 +52,8 @@ module XlsxParser
52
52
  worksheet = $xlsxDoc[0]
53
53
  # get the remaining test data
54
54
  $testDes = worksheet.sheet_data[4][1].value
55
- puts "Number of test steps: #{$numberOfTestSteps}"
56
- puts "Test Description: #{$testDes}"
55
+ MyLog.log.info "Number of test steps: #{$numberOfTestSteps}"
56
+ MyLog.log.info "Test Description: #{$testDes}"
57
57
 
58
58
  end
59
59
 
@@ -59,7 +59,7 @@ module JunitReport
59
59
  if !File.exist?($TestSuiteSummaryXML) || $TestSuiteSummaryXML.closed?
60
60
  $testSuiteSummaryFile_xml = File.open($TestSuiteSummaryXML, 'w+')
61
61
  $testSuiteSummaryFile_xml.write builder.to_xml
62
- elsif $log.puts "test suite summary file xml name: #{$TestSuiteSummaryXML} is already open"
62
+ elsif MyLog.log.warn "test suite summary file xml name: #{$TestSuiteSummaryXML} is already open"
63
63
  end
64
64
 
65
65
  # if the file is open then close it
@@ -6,54 +6,15 @@
6
6
  # Versions:
7
7
  # 1.0 - Baseline
8
8
  #
9
- # report.rb - methods for accessing and writing to the test report file(s)
9
+ # report.rb - methods for outputting console.
10
10
  module Report
11
11
  require_relative '../taf_config.rb'
12
12
  # setup the test results output file
13
- def self.open_test_report_file
14
- # open a new file for writing
15
- $log.puts("Opening Test Result file: #{$testResultFileName} \n")
16
-
17
- # open test results file for writing if not already open
18
- if !File.exist?($testResultFileName) || $testResultFileName.closed?
19
- @results_file = File.open($testResultFileName, 'w')
20
- elsif $log.puts "test results file name: #{$testResultFileName} is already open"
21
- end
22
- end
23
-
24
- # close_testresults_file
25
- def self.close_test_results_file
26
- # if the file is open then close it
27
- Report.results.close unless Report.results.closed?
28
- end
29
-
30
13
  # results file variable
31
14
  def self.results
32
15
  results_file = @results_file
33
16
  end
34
17
 
35
- def self.open_log_file
36
- # open a new file for writing
37
- $stdout.puts "Opening log file: #{$logFileName} \n"
38
-
39
- # create a new log file and set the mode as 'append'
40
- $log = File.open($logFileName, 'w+')
41
- end
42
-
43
- def self.close_log_file
44
- # if the file is open then close it
45
- $log.close unless $log.closed?
46
- end
47
-
48
- # print the main test header info to the test results file
49
- def self.print_test_header
50
- Report.results.puts("Project Name: #{$projectName} Project ID: #{$projectId} Sprint: #{$sprint}")
51
- Report.results.puts("Test ID: #{$testId} Test Description: #{$testDes}")
52
- Report.results.puts("Executed with browser: #{$browserType}")
53
- Report.results.puts("Test suite: #{$testSuiteFile}")
54
- Report.results.puts("Tester: #{$tester}", "\n \n")
55
- end
56
-
57
18
  # get the current time in the format Day - Month - Date - Time (HH:MM:SS)
58
19
  def self.current_time
59
20
  time = Time.new
@@ -63,10 +24,8 @@ module Report
63
24
 
64
25
  # print the test Step info to the test results file
65
26
  def self.print_test_step_header(test_file_name, testStepIndex)
66
- Report.results.puts("\n" + "Test start time: #{f_time = current_time}")
67
- Report.results.puts("Test step: #{$testStep} : #{$testStepDes} \n")
68
- puts "\nTest start time: #{f_time = current_time} \n"
69
- puts "Test step: #{$testStep} : #{$testStepDes} "
27
+ MyLog.log.info "Test start time: #{f_time = current_time}"
28
+ MyLog.log.info "Test step: #{$testStep} : #{$testStepDes}"
70
29
 
71
30
  step = {
72
31
  'id' => $testStep,
@@ -89,14 +48,12 @@ module Report
89
48
  $previousTestFail = $currentTestFail
90
49
  $currentTestFail = false
91
50
  $testStepPasses += 1
92
- Report.results.puts("Test #{$testStep} has Passed")
93
- puts "Test #{$testStep} has Passed ".green
51
+ MyLog.log.info "Test #{$testStep} has Passed ".green
94
52
  elsif passFail == false
95
53
  $previousTestFail = $currentTestFail
96
54
  $currentTestFail = true
97
55
  $testStepFailures += 1
98
- Report.results.puts("Test #{$testStep} has FAILED")
99
- puts "Test #{$testStep} has FAILED ".red
56
+ MyLog.log.info "Test #{$testStep} has FAILED ".red
100
57
  failstep = {
101
58
  'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $testStep.to_s + ' Test has FAILED - Check logs',
102
59
  'type' => 'FAILURE',
@@ -112,8 +69,7 @@ module Report
112
69
  else
113
70
  $currentTestFail = false
114
71
  $testStepNotrun += 1
115
- Report.results.puts("Test #{$testStep} no checks performed")
116
- puts "Test #{$testStep} no checks performed ".blue
72
+ MyLog.log.info "Test #{$testStep} no checks performed ".blue
117
73
  skipstep = {
118
74
  'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $testStep.to_s + ' No checks performed - Check logs',
119
75
  'type' => 'SKIPPED',
@@ -127,8 +83,7 @@ module Report
127
83
  $skiptestStep_xml[test_file_name] ||= []
128
84
  $skiptestStep_xml[test_file_name][testStepIndex] = skipstep
129
85
  end
130
- Report.results.puts("Test end time: #{f_time = current_time}\n")
131
- puts "Test end time: #{f_time = current_time} \n"
86
+ MyLog.log.info "Test end time: #{f_time = current_time}"
132
87
  end
133
88
 
134
89
  # check if the test failure threshold has been reached for total failures or consecutive failures.
@@ -142,11 +97,9 @@ module Report
142
97
  end
143
98
 
144
99
  if @consecutiveTestFail >= consecutiveFailThreshold
145
- Report.results.puts("\nTerminating the current test case as the test failure threshold (#{consecutiveFailThreshold} ) has been reached")
146
-
147
- # write info to $stderr
148
- $stderr.puts "Terminating the current test case: #{test_file_name} as the test failure threshold (#{consecutiveFailThreshold}) has been reached."
149
- $stderr.puts '...continuing with the next test case (if there is one)'
100
+ # write info to stdout
101
+ MyLog.log.warn "Terminating the current test case: #{test_file_name} as the test failure threshold (#{consecutiveFailThreshold}) has been reached."
102
+ MyLog.log.warn '...continuing with the next test case (if there is one)'
150
103
 
151
104
  raise FailureThresholdExceeded,
152
105
  "#{consecutiveFailThreshold} Test Steps Failed."
@@ -14,7 +14,7 @@ module ReportSummary
14
14
  # output the test results summary for the current test case
15
15
  def self.test_step_summary(test_file_name, test_file_name_index)
16
16
  # construct the test step report summary
17
- @testStepReportSummary[test_file_name_index] = "\n" 'Test file:', test_file_name,\
17
+ @testStepReportSummary[test_file_name_index] = 'Test file:', test_file_name,\
18
18
  "\n" 'Browser type:', $browserType, \
19
19
  "\n" 'Browser version:', Browser.browser_version.to_s, \
20
20
  "\n" 'Environment:', $env_type, \
@@ -25,38 +25,35 @@ module ReportSummary
25
25
  "\n" 'There are:', $testStepNotrun, 'Skipped Tests' "\n"
26
26
  # ... and save in a format that is printable
27
27
  @testStepReportSummary[test_file_name_index] = @testStepReportSummary[test_file_name_index].join(' ')
28
- Report.results.puts ''
29
- Report.results.puts("Test Summary: #{@testStepReportSummary[test_file_name_index]}")
30
- Report.results.puts("Test end time: #{$test_case_end_time} \n")
31
28
  end
32
29
 
33
30
  # output the overall test results summary
34
31
  def self.print_overall_test_summary
35
32
  # output to the console
36
33
 
37
- puts "\nFinished processing all test files - executed via test suite: #{$testSuiteFile} by tester: #{$tester}"
38
- puts "\nOverall Test Summary:"
34
+ MyLog.log.info "Finished processing all test files - executed via test suite: #{$testSuiteFile} by tester: #{$tester}"
35
+ MyLog.log.info "Overall Test Summary:"
39
36
  @testStepReportSummary.each do |testStepReportSummary|
40
- puts testStepReportSummary
37
+ MyLog.log.info testStepReportSummary
41
38
  end
42
39
 
43
- puts "\nTotal Tests started at: #{$test_start_time}"
44
- puts "Total Tests finished at: #{$test_end_time}"
45
- puts ('Total Tests duration: ' + TimeDifference.between($test_end_time, $test_start_time).humanize)
46
- puts "Total Tests Passed: #{$totalTestPasses}".green
47
- puts "Total Tests Failed: #{$totalTestFailures}".red
48
- puts "Total Tests Skipped: #{$totalTestNotrun}".blue
40
+ MyLog.log.info "Total Tests started at: #{$test_start_time}"
41
+ MyLog.log.info "Total Tests finished at: #{$test_end_time}"
42
+ MyLog.log.info ('Total Tests duration: ' + TimeDifference.between($test_end_time, $test_start_time).humanize)
43
+ MyLog.log.info "Total Tests Passed: #{$totalTestPasses}".green
44
+ MyLog.log.info "Total Tests Failed: #{$totalTestFailures}".red
45
+ MyLog.log.info "Total Tests Skipped: #{$totalTestNotrun}".blue
49
46
  $totalTests = [$totalTestPasses, $totalTestFailures, $totalTestNotrun].sum
50
- puts "Total Tests: #{$totalTests}\n"
47
+ MyLog.log.info "Total Tests: #{$totalTests}\n"
51
48
 
52
49
  # output to the suite summary file
53
50
 
54
51
  # open the suite summary file for writing if not already open
55
52
  if !File.exist?($testSuiteSummaryFileName) || $testSuiteSummaryFileName.closed?
56
53
  testSuiteSummaryFile = File.open($testSuiteSummaryFileName, 'w')
57
- puts "\nTest Suite Summary file located at:"
58
- puts "#{$testSuiteSummaryFileName}\n"
59
- elsif $log.puts "test suite summary file name: #{$testSuiteSummarylFileName} is already open"
54
+ MyLog.log.info"Test Suite Summary file located at:"
55
+ MyLog.log.info "#{$testSuiteSummaryFileName}\n"
56
+ elsif MyLog.log.warn "test suite summary file name: #{$testSuiteSummarylFileName} is already open"
60
57
  end
61
58
 
62
59
  testSuiteSummaryFile.puts "Finished processing all test files - executed via test suite: #{$testSuiteFile} by tester: #{$tester} \n"
@@ -25,6 +25,7 @@ require_relative './utils/test_steps'
25
25
  require_relative './report/report'
26
26
  require_relative './utils/browser'
27
27
  require_relative './utils/create_directories'
28
+ require_relative './utils/logger'
28
29
  require_relative './utils/test_engine'
29
30
  require_relative './utils/exceptions'
30
31
  require_relative './report/junit_report'
@@ -24,7 +24,7 @@ module Browser
24
24
  when 'safari'
25
25
  safari
26
26
  else
27
- puts "unable to open selected browser: #{lc_browser_type}"
27
+ MyLog.log.error "unable to open selected browser: #{lc_browser_type}"
28
28
  raise BrowserFailedOpen
29
29
  end
30
30
  rescue BrowserFailedOpen => error
@@ -126,15 +126,15 @@ module Browser
126
126
 
127
127
  # Screenshot capture for websites
128
128
  Browser.b.screenshot.save scFileName
129
- Report.results.puts("Screenshot saved to: #{scFileName}")
129
+ MyLog.log.info("Screenshot saved to: #{scFileName} \n")
130
130
  else
131
- Report.results.puts 'No screenshot requested'
131
+ MyLog.log.debug "No screenshot requested \n"
132
132
  end
133
133
 
134
134
  # if any issues with saving the screenshot then log a warning
135
135
  rescue StandardError => error
136
136
  # construct the error message from custom text and the actual system
137
137
  # error message (converted to a string).
138
- $log.puts("Error saving the screenshot: #{scFileName} #{error.to_s}")
138
+ MyLog.log.warn("Error saving the screenshot: #{scFileName} #{error.to_s}")
139
139
  end
140
140
  end
@@ -20,8 +20,6 @@ module CreateDirectories
20
20
  #
21
21
  # ---------->directory named after test_id (with browser type identified)
22
22
  #
23
- # ------------->directory named 'Test_Results'
24
- #
25
23
  # ------------->directory named 'Screenshots'
26
24
 
27
25
  def self.construct_projectdirs
@@ -53,18 +51,10 @@ module CreateDirectories
53
51
  screenshot_dir = testid_dir + '/' + 'Screenshots' + '/'
54
52
  Dir.mkdir(screenshot_dir)
55
53
 
56
- # create a test results directory under the 'test run' directory - it will always need creating
57
- test_res_dir = testid_dir + '/' + 'Test_Results' + '/'
58
- Dir.mkdir(test_res_dir)
59
-
60
54
  # create absolute paths to the screenshots, test results and test suite summary directories
61
55
  abs_path_screenshot_dir = File.absolute_path(screenshot_dir)
62
- abs_path_test_res_dir = File.absolute_path(test_res_dir)
63
56
  abs_path_run_no_dir = File.absolute_path($runNoDir)
64
57
 
65
- # the test results file name will be 'testId'_Res.txt
66
- $testResultFileName = abs_path_test_res_dir + '/' + $testId + '_Res.txt'
67
-
68
58
  # the test suite summary file name will be 'suite_summary.txt'
69
59
  $testSuiteSummaryFileName = abs_path_run_no_dir + '/suite_summary.txt'
70
60
 
@@ -76,11 +66,9 @@ module CreateDirectories
76
66
  $TestSuiteSummaryXML = 'Results/' + $projectId + '/' + f_date + '_' + f_time + '_test_result.xml'
77
67
 
78
68
  # the log file name will be under the test ID directory
79
- $logFileName = testid_dir + '/TestLogFile.txt'
80
69
 
81
- puts "TestId: #{$testId}"
82
- puts "Screenshot directory: #{abs_path_screenshot_dir}"
83
- puts "Test result directory: #{abs_path_test_res_dir}"
70
+ MyLog.log.info "TestId: #{$testId}"
71
+ MyLog.log.info "Screenshot directory: #{abs_path_screenshot_dir} \n"
84
72
 
85
73
  # if any issues then set error message and re-raise the exception
86
74
  rescue Exception => error
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Created on 04 Feb 2019
4
+ # @author: Andy Perrett
5
+ #
6
+ # Versions:
7
+ # 1.0 - Baseline
8
+ #
9
+ # logger.rb - logger file
10
+
11
+ module MyLog
12
+ require_relative '../taf_config.rb'
13
+ def self.log
14
+ if @logger.nil?
15
+ @logger = Logger.new STDOUT
16
+ @logger.level = Logger::DEBUG
17
+ @logger.datetime_format = '%Y-%m-%d %H:%M:%S '
18
+ end
19
+ @logger
20
+ end
21
+ end
@@ -36,13 +36,10 @@ module TestEngine
36
36
 
37
37
  if ARGV.length < 2
38
38
  $browserType = test_suite[:browser]
39
- puts ''
40
- puts "Will use the following browser from Test Suite: #{$browserType}"
41
- puts ''
39
+ MyLog.log.info "Will use the following browser from Test Suite: #{$browserType}"
42
40
  elsif ARGV.length < 3
43
41
  $browserType = ARGV[1]
44
- puts "\nWill use the following browser from CMD line: " + ARGV[1]
45
- puts ''
42
+ MyLog.log.info "Will use the following browser from CMD line: " + ARGV[1]
46
43
  else
47
44
  raise IOError, 'Unable to open browser'
48
45
  end
@@ -56,37 +53,27 @@ module TestEngine
56
53
  # if unable to read the test data, show the error and move onto the
57
54
  # next file (if there is one)
58
55
  rescue StandardError => error
59
- $stderr.puts "Terminating the current test case: " \
56
+ MyLog.log.warn "Terminating the current test case: " \
60
57
  "#{test_file_name} #{error}"
61
- $stderr.puts '...continuing with the next test case (if there is one)'
58
+ MyLog.log.info '...continuing with the next test case (if there is one)'
62
59
  end # of rescue block for readTestData
63
60
 
64
61
  # create the project directories, returns the screenshot directory name
65
62
  begin # start of rescue block for construct_projectdirs
66
63
  # create test spec directories - these need creating once per testspec
67
64
  full_sc_dirname = CreateDirectories.construct_testspecdirs
68
- # open the log file
69
- Report.open_log_file
70
65
  # if an error then show the error and terminate
71
66
  rescue StandardError => error
72
67
  warn error
73
- $stdout.puts error
68
+ MyLog.log.warn error
74
69
  abort
75
70
  end
76
71
 
77
- # open the test results output file
78
- Report.open_test_report_file
79
-
80
- # print the main test header
81
- Report.print_test_header
82
-
83
72
  # loop through the test file
84
73
  if testFileType != 'XLSX'
85
74
  puts 'Not a valid XLSX File Type'
86
75
  end
87
76
 
88
- Report.results.puts("Number of test steps: #{$numberOfTestSteps}")
89
-
90
77
  # get the test case start time
91
78
  $test_case_start_time = Report.current_time
92
79
  # initialise the test end time
@@ -118,12 +105,6 @@ module TestEngine
118
105
  ReportSummary.test_step_summary(test_file_name, test_file_name_index)
119
106
  JunitReport.test_step_summary_xml(test_file_name, test_file_name_index)
120
107
 
121
- # close the test results file for the current test case
122
- Report.close_test_results_file
123
-
124
- # close the log file
125
- Report.close_log_file
126
-
127
108
  # close the browser if created
128
109
  Browser.b.quit
129
110
 
@@ -30,8 +30,7 @@ module TestSteps
30
30
  Report.check_failure_threshold(test_file_name, teststepindex)
31
31
  return true
32
32
  else
33
- Report.results.puts("\nUnable to match function: #{step_function}")
34
- puts "\nUnable to match function: #{step_function}"
33
+ MyLog.log.warn "\nUnable to match function: #{step_function}"
35
34
  raise UnknownTestStep, "Unknown test step: #{step_function}"
36
35
  return false
37
36
  end
@@ -3,7 +3,7 @@
3
3
  module Taf
4
4
  # This module holds the TAF version information.
5
5
  module Version
6
- STRING = '0.1.5'.freeze
6
+ STRING = '0.1.6'.freeze
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
9
9
  '%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'.freeze
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.1.5
4
+ version: 0.1.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-01-11 00:00:00.000000000 Z
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -211,6 +211,7 @@ files:
211
211
  - lib/utils/browser.rb
212
212
  - lib/utils/create_directories.rb
213
213
  - lib/utils/exceptions.rb
214
+ - lib/utils/logger.rb
214
215
  - lib/utils/test_engine.rb
215
216
  - lib/utils/test_steps.rb
216
217
  - lib/version.rb