taf 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68dc766c595d259d02242dfc34a39309531aa63ffabc912ffc85c9cad2ceb46b
4
- data.tar.gz: cf0d163c682cebe8c794c19281dc18006ecceae413030e6e81a11ae9e09c5f76
3
+ metadata.gz: 8547dfd48a03b189469331103f5fe10b053b8761c1b25bdce6e069b9808c264c
4
+ data.tar.gz: 35b82be0e8d1f7ee7d7146a16aaecc5cb09914519ac31a4c36d4dad5cd473bf5
5
5
  SHA512:
6
- metadata.gz: ad1dc2b44ccf4f29566adcfee38f679560cb1e5b8d040dd169a44e0d19073416bae4f9dab681189caa3cedc71f0c0b92d27ac6503278a1de58114bb949ca8767
7
- data.tar.gz: 689cb611844b398d6f04148916c25c87136e6ec65612c1612ed18458323fb25aef0c1cd83b41838f80ad1a49079f24eb5568210e95ec8e758b3cc1e3561d9b9a
6
+ metadata.gz: 98dd2ffb3dbf3be2fc7beb897a9453ff2f6ad48645da9cb663538ac92f909a5e615452f6766be6c9f70541b08a67666de5a829b909600982019aa8a2db4fc533
7
+ data.tar.gz: 1d934465ba76c51574fcbda69d930a9809e9c46fbca9ded3b858e6819d42eaadc00d2d264f1d10b0f7f9c091333d417d8bf2e9aaf68e7f70152aa003955f5786
data/lib/main.rb CHANGED
@@ -71,8 +71,6 @@ module Main
71
71
  $totalTestNotrun = 0
72
72
  $previousTestFail = false
73
73
  $currentTestFail = false
74
- # initialised stores for the input xlsx test data
75
- $XlsxDoc = ''
76
74
  # parses the cmd line imput into the taf
77
75
  Main.cmdline_input
78
76
  end
@@ -0,0 +1,42 @@
1
+ # Created on 02 Aug 2018
2
+ # @author: Andy Perrett
3
+ #
4
+ # Versions:
5
+ # 1.0 - Baseline
6
+ #
7
+ # json_parser.rb - json parser functions
8
+ module JsonParser
9
+ require_relative '../taf_config.rb'
10
+
11
+ def self.parse_test_header_data(parse_json)
12
+ # get the number of test steps in the file
13
+ $numberOfTestSteps = parse_json['steps'].count
14
+ # get the remaining test data
15
+ $testId = parse_json['testId']
16
+ $projectId = parse_json['projectId']
17
+ $testDes = parse_json['testDescription']
18
+ MyLog.log.info "Number of test steps: #{$numberOfTestSteps}"
19
+ MyLog.log.info "Test Description: #{$testDes}"
20
+ MyLog.log.info "TestID: #{$testId} \n"
21
+ end
22
+
23
+ # parseTestStepData
24
+ def self.parse_test_step_data(parse_json)
25
+ parsed_step = {
26
+ testStep: parse_json['currentStep'],
27
+ testdesc: parse_json['description'],
28
+ testFunction: parse_json['function'].downcase,
29
+ testvalue: parse_json['value0'],
30
+ locate: parse_json['value1'] || 'id',
31
+ testvalue2: parse_json['value2'],
32
+ locate2: parse_json['value3'] || 'id',
33
+ screenShotData: parse_json['screenshot'] == 'yes',
34
+ skipTestCase: parse_json['skipTestCase'] == 'yes'
35
+ }
36
+
37
+ parsed_step
38
+ # if an error reading the test step data then re-raise the exception
39
+ rescue StandardError => error
40
+ raise error
41
+ end
42
+ end
data/lib/parser/parser.rb CHANGED
@@ -7,11 +7,9 @@
7
7
  # parser.rb - basic parser functions
8
8
  module Parser
9
9
  require_relative '../taf_config.rb'
10
- # variables:
11
- @xlsx_file_name_type = '.xlsx'
12
10
 
13
11
  def self.test_files
14
- @test_files ||= Dir.glob("#{$testcasesFolder}/*.xlsx").reject do |file|
12
+ @test_files ||= Dir.glob("#{$testcasesFolder}/*.json").reject do |file|
15
13
  File.basename(file).start_with?('~$')
16
14
  end.sort
17
15
  end
@@ -20,17 +18,20 @@ module Parser
20
18
  def self.read_test_data(test_file_name)
21
19
  # get the file type
22
20
  file_type = File.extname(test_file_name)
23
- if file_type.casecmp(@xlsx_file_name_type).zero?
21
+ if file_type.casecmp('.json').zero?
24
22
  MyLog.log.info "Processing test file: #{test_file_name}"
25
23
  MyLog.log.info "Browser Type: #{$browserType}"
26
- $xlsxDoc = RubyXL::Parser.parse(test_file_name)
27
- XlsxParser.parse_xlxs_test_header_data
28
- return 'XLSX'
24
+ json = File.read(test_file_name)
25
+ parse_json = JSON.parse(json)
26
+
27
+ JsonParser.parse_test_header_data(parse_json)
28
+ return parse_json
29
29
  else
30
30
  # if unable to read the test file list then construct a custom error
31
31
  # message and raise an exception.
32
+ MyLog.log.info 'Not a valid JSON File Type' if test_file_name != 'JSON'
32
33
  error_to_display = "Test File Name: '#{test_file_name}' " \
33
- 'type not recognised (must be .xslx)'
34
+ 'type not recognised (must be .xslx or .json)'
34
35
  raise IOError, error_to_display
35
36
  end
36
37
 
@@ -41,7 +42,7 @@ module Parser
41
42
  end
42
43
 
43
44
  # parseTestStepData
44
- def self.parse_test_step_data(test_file_type)
45
- XlsxParser.parse_test_step_data(test_file_type)
45
+ def self.parse_test_step_data(parse_json)
46
+ JsonParser.parse_test_step_data(parse_json)
46
47
  end
47
48
  end
data/lib/report/report.rb CHANGED
@@ -16,14 +16,14 @@ module Report
16
16
  end
17
17
 
18
18
  # print the test Step info to the test results file
19
- def self.print_test_step_header(test_file_name, test_step_index)
19
+ def self.print_test_step_header(test_file_name, test_step_index, step_attributes)
20
20
  @test_start_time = current_time
21
- MyLog.log.info "Test step: #{$test_step} : #{$test_step_des}"
21
+ MyLog.log.info "Test step: #{step_attributes[:testStep]} : #{step_attributes[:testdesc]}"
22
22
 
23
23
  step = {
24
- 'id' => $test_step,
25
- 'classname' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $test_step.to_s + ' ' + $test_step_des.to_s,
26
- 'name' => $test_step_des,
24
+ 'id' => step_attributes[:testStep],
25
+ 'classname' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + step_attributes[:testStep].to_s + ' ' + step_attributes[:testdesc].to_s,
26
+ 'name' => step_attributes[:testdesc],
27
27
  'file' => test_file_name
28
28
  }
29
29
  # output to console to show test step
@@ -37,19 +37,19 @@ module Report
37
37
  end
38
38
 
39
39
  # print the Pass / Fail status of a test to the test results file
40
- def self.test_pass_fail(pass_fail, test_file_name, test_step_index)
40
+ def self.test_pass_fail(pass_fail, test_file_name, test_step_index, step_attributes)
41
41
  if pass_fail == true
42
42
  $previousTestFail = $currentTestFail
43
43
  $currentTestFail = false
44
44
  $testStepPasses += 1
45
- MyLog.log.info "Test #{$test_step} has Passed ".green
45
+ MyLog.log.info "Test #{step_attributes[:testStep]} has Passed ".green
46
46
  elsif pass_fail == false
47
47
  $previousTestFail = $currentTestFail
48
48
  $currentTestFail = true
49
49
  $testStepFailures += 1
50
- MyLog.log.info "Test #{$test_step} has FAILED ".red
50
+ MyLog.log.info "Test #{step_attributes[:testStep]} has FAILED ".red
51
51
  failstep = {
52
- 'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $test_step.to_s + ' Test has FAILED - Check logs',
52
+ 'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + step_attributes[:testStep].to_s + ' Test has FAILED - Check logs',
53
53
  'type' => 'FAILURE',
54
54
  'file' => test_file_name
55
55
  }
@@ -64,9 +64,9 @@ module Report
64
64
  else
65
65
  $currentTestFail = false
66
66
  $testStepNotrun += 1
67
- MyLog.log.info "Test #{$test_step} no checks performed ".blue
67
+ MyLog.log.info "Test #{step_attributes[:testStep]} no checks performed ".blue
68
68
  skipstep = {
69
- 'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + $test_step.to_s + ' No checks performed - Check logs',
69
+ 'message' => 'SuiteID: ' + $testId.to_s + ' Test Step: ' + step_attributes[:testStep].to_s + ' No checks performed - Check logs',
70
70
  'type' => 'SKIPPED',
71
71
  'file' => test_file_name
72
72
  }
data/lib/taf_config.rb CHANGED
@@ -18,10 +18,10 @@ require 'net/ping'
18
18
  require 'nokogiri'
19
19
  require 'time_difference'
20
20
  require 'colored'
21
- require 'rubyXL'
22
21
  require 'optparse'
23
22
  require 'fileutils'
24
23
  require 'securerandom'
24
+ require 'json'
25
25
 
26
26
  # list of all the required files
27
27
  require_relative './utils/test_steps'
@@ -34,7 +34,7 @@ require_relative './utils/exceptions'
34
34
  require_relative './report/junit_report'
35
35
  require_relative './report/report_summary'
36
36
  require_relative './parser/parser'
37
- require_relative './parser/xlsx_parser'
37
+ require_relative './parser/json_parser'
38
38
 
39
39
  # Require all test step handlers, which register themselves with
40
40
  # TestStep.handlers when the files are required.
@@ -19,7 +19,7 @@ module TestEngine
19
19
  Parser.test_files.each_with_index do |test_file_name, test_file_index|
20
20
  begin
21
21
  # read in the test data
22
- test_file_type = Parser.read_test_data(test_file_name)
22
+ tests = Parser.read_test_data(test_file_name)
23
23
  # if unable to read the test data, show the error and move onto the
24
24
  # next file (if there is one)
25
25
  rescue StandardError => error
@@ -31,26 +31,18 @@ module TestEngine
31
31
  # create project folders - these only need creating once per test suite
32
32
  CreateDirectories.construct_projectdirs
33
33
 
34
- # loop through the test file
35
- MyLog.log.info 'Not a valid XLSX File Type' if test_file_type != 'XLSX'
36
-
37
34
  # get the test case start time
38
35
  $test_case_start_time = Report.current_time
39
36
  # initialise the test end time
40
37
  $test_case_end_time = Report.current_time
41
38
 
42
39
  begin
43
- test_steps = Parser.parse_test_step_data(test_file_type)
44
-
45
- test_steps.each_with_index do |test_step, step_index|
46
- $test_step = test_step[:testStep]
47
- $test_step_des = test_step[:testdesc]
48
- screen_shot = test_step[:screenShotData]
49
-
40
+ tests['steps'].each do |test_step|
41
+ parsed_steps = Parser.parse_test_step_data(test_step)
50
42
  # process the test step data
51
- TestSteps.process_test_steps(test_file_name, step_index, test_step)
43
+ TestSteps.process_test_steps(test_file_name, parsed_steps[:testStep], parsed_steps)
52
44
  # see if screenshot required
53
- Browser.check_save_screenshot(screen_shot)
45
+ Browser.check_save_screenshot(parsed_steps[:screenShotData])
54
46
  end
55
47
  rescue TafError => error
56
48
  warn error
@@ -18,15 +18,14 @@ module TestSteps
18
18
  # processing the associated data accordingly
19
19
  def self.process_test_steps(test_file_name, test_step_index, step_attributes)
20
20
  # print the test step information
21
- Report.print_test_step_header(test_file_name, test_step_index)
22
-
21
+ Report.print_test_step_header(test_file_name, test_step_index, step_attributes)
23
22
  runtest = step_attributes[:skipTestCase]
24
23
  step_function = step_attributes[:testFunction]
25
24
  handler = handlers[step_function.to_s]
26
25
 
27
26
  if handler.respond_to?(:perform)
28
27
  func = handler.perform(step_attributes) if runtest == false
29
- Report.test_pass_fail(func, test_file_name, test_step_index)
28
+ Report.test_pass_fail(func, test_file_name, test_step_index, step_attributes)
30
29
  Report.check_failure_threshold(test_file_name, test_step_index)
31
30
  return true
32
31
  else
data/lib/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Taf
4
4
  # This module holds the TAF version information.
5
5
  module Version
6
- STRING = '0.2.6'
6
+ STRING = '0.2.7'
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)'
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.2.6
4
+ version: 0.2.7
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-04-30 00:00:00.000000000 Z
11
+ date: 2019-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.2'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: logger
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +122,6 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '2.7'
111
- - !ruby/object:Gem::Dependency
112
- name: rubyXL
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '3.3'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '3.3'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: selenium-webdriver
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -199,8 +199,8 @@ files:
199
199
  - lib/functions/handlers/send_special_keys.rb
200
200
  - lib/functions/handlers/write_box_data.rb
201
201
  - lib/main.rb
202
+ - lib/parser/json_parser.rb
202
203
  - lib/parser/parser.rb
203
- - lib/parser/xlsx_parser.rb
204
204
  - lib/report/junit_report.rb
205
205
  - lib/report/report.rb
206
206
  - lib/report/report_summary.rb
@@ -1,72 +0,0 @@
1
- # Created on 02 Aug 2018
2
- # @author: Andy Perrett
3
- #
4
- # Versions:
5
- # 1.0 - Baseline
6
- #
7
- # xlsx_parser.rb - xlsx parser functions
8
- module XlsxParser
9
- require_relative '../taf_config.rb'
10
-
11
- def self.parse_xlxs_test_header_data
12
- # get the number of test steps in the file
13
- $numberOfTestSteps = $xlsxDoc[0].sheet_data.size - 4
14
- worksheet = $xlsxDoc[0]
15
- # get the remaining test data
16
- $testId = worksheet.sheet_data[1][0].value
17
- $projectId = worksheet.sheet_data[1][1].value
18
- $testDes = worksheet.sheet_data[1][2].value
19
- MyLog.log.info "Number of test steps: #{$numberOfTestSteps}"
20
- MyLog.log.info "Test Description: #{$testDes}"
21
- MyLog.log.info "TestID: #{$testId} \n"
22
- end
23
-
24
- # parseTestStepData
25
- def self.parse_test_step_data(_test_file_type)
26
- worksheet = $xlsxDoc[0]
27
- worksheet[4..$numberOfTestSteps + 4].map do |row|
28
- test = {
29
- testStep: row[0].value,
30
- testdesc: row[1].value,
31
- testFunction: row[2].value,
32
- testvalue: row[3].value,
33
- locate: row[4].value,
34
- testvalue2: row[5].value,
35
- locate2: row[6].value,
36
- screenShotData: row[7].value,
37
- skipTestCase: row[8].value
38
- }
39
-
40
- # convert test step, screenshot and skip test case functions to lowercase.
41
- test[:testFunction].downcase!
42
-
43
- # get screenshot request, check for a null value and default to 'N'
44
-
45
- test[:screenShotData] = if test[:screenShotData] == 'Y'
46
- true
47
- elsif test[:screenShotData] == 'N'
48
- false
49
- else
50
- false
51
- end
52
-
53
- test[:skipTestCase] = if test[:skipTestCase] == 'Y'
54
- true
55
- elsif test[:skipTestCase] == 'N'
56
- false
57
- else
58
- false
59
- end
60
-
61
- # if there is an element locator then use it, otherwise use an ID
62
- test[:locate] = 'id' if test[:locate].to_s == ''
63
-
64
- test[:locate2] = 'id' if test[:locate2].to_s == ''
65
-
66
- test
67
- # if an error reading the test step data then re-raise the exception
68
- rescue StandardError => error
69
- raise error
70
- end
71
- end
72
- end