taf 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/main.rb +10 -15
- data/lib/parser/parser.rb +4 -43
- data/lib/parser/xlsx_parser.rb +6 -41
- data/lib/report/junit_report.rb +2 -2
- data/lib/report/report_summary.rb +3 -4
- data/lib/utils/browser.rb +3 -1
- data/lib/utils/create_directories.rb +12 -17
- data/lib/utils/test_engine.rb +60 -104
- 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: c5a4ea4d70ac8bd18bd9e90fa0b0b1615e036669df29d789105cec6aa5d74e09
|
4
|
+
data.tar.gz: 4d62ee8db6590f1ed95be8dbabdb2db2e220d9e5f5bad68d73b1266eb8cf084b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7f1b953e22f15a8152110c5621c824535efb13e0921c6961a07e90cb1f3165a0ead74a87ccf8502c0c086a4c7899c74c55a4934cf2952d271f2045df28647d0
|
7
|
+
data.tar.gz: dddad76d0929978d394fa1e8639288b84ecf445fa4d79a03e81d34b7a1168445c08dbbdb82f2ab71168ca3324ff4702b5db2b0c3a9104e5aa88c37b9e8ce3d56
|
data/lib/main.rb
CHANGED
@@ -28,25 +28,20 @@ module Main
|
|
28
28
|
|
29
29
|
begin
|
30
30
|
# check if the test suite file name exists on the command line
|
31
|
-
# allow a user to input
|
32
|
-
#
|
33
|
-
if ARGV.length <
|
34
|
-
$
|
35
|
-
MyLog.log.info 'Only one argument needed: {TestSuite File}'
|
36
|
-
elsif ARGV.length < 3
|
37
|
-
$testSuiteFile = ARGV[0]
|
31
|
+
# allow a user to input 2 arguments in to CMD line the 2 values are:
|
32
|
+
# Testcase Folder and Browser.
|
33
|
+
if ARGV.length < 3
|
34
|
+
$testcasesFolder = ARGV[0]
|
38
35
|
$browserType = ARGV[1]
|
39
|
-
MyLog.log.info '
|
36
|
+
MyLog.log.info '2 arguments are required: {Testcase folder} {Browser}'
|
40
37
|
else
|
41
38
|
# unable to open file as not supplied as command-line parameter
|
42
|
-
$
|
43
|
-
error_to_display = 'Test
|
39
|
+
$testcasesFolder = 'unknown'
|
40
|
+
error_to_display = 'Test case location has not been supplied as a command-line parameter as expected'
|
41
|
+
$browserType = 'unknown'
|
42
|
+
error_to_display = 'Browser has not been supplied as a command-line parameter as expected'
|
44
43
|
raise IOError, error_to_display
|
45
44
|
end
|
46
|
-
|
47
|
-
# Get the test suite data
|
48
|
-
Parser.read_test_suite_data
|
49
|
-
|
50
45
|
# unable to read the test file then handle the error and terminate
|
51
46
|
rescue StandardError => error
|
52
47
|
warn error
|
@@ -54,7 +49,7 @@ module Main
|
|
54
49
|
abort
|
55
50
|
end
|
56
51
|
|
57
|
-
MyLog.log.info "There are: #{
|
52
|
+
MyLog.log.info "There are: #{Parser.test_files.size} test files to process \n"
|
58
53
|
|
59
54
|
# process the test files to execute the tests
|
60
55
|
TestEngine.process_testfiles
|
data/lib/parser/parser.rb
CHANGED
@@ -10,49 +10,10 @@ module Parser
|
|
10
10
|
# variables:
|
11
11
|
@XlsxFileNameType = '.xlsx'
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
MyLog.log.info "Processing test suite file: #{$testSuiteFile}"
|
18
|
-
# get the file type
|
19
|
-
fileType = File.extname($testSuiteFile)
|
20
|
-
# extract the test data from the test suite
|
21
|
-
if (fileType.casecmp(@XlsxFileNameType) == 0)
|
22
|
-
# process as xlsx...
|
23
|
-
$XlsxSuiteDoc = RubyXL::Parser.parse($testSuiteFile)
|
24
|
-
# ...and parse...
|
25
|
-
XlsxParser.parse_xlxs_test_suite_header_data
|
26
|
-
else
|
27
|
-
# the file type is not that expected so create
|
28
|
-
# a error message and raise an exception
|
29
|
-
error_to_display = "Test Suite file: '#{$testSuiteFile}' "\
|
30
|
-
"type not recognised (must be .xlsx)"
|
31
|
-
raise IOError, error_to_display
|
32
|
-
end
|
33
|
-
# if unable to read the test file list then construct
|
34
|
-
# a custom error message and raise an exception
|
35
|
-
elsif error_to_display = "Test Suite file: '#{$testSuiteFile}' "\
|
36
|
-
"does not exist or is unreadable"
|
37
|
-
raise IOError, error_to_display
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.parse_test_suite_data(testSpecIndex)
|
42
|
-
begin
|
43
|
-
# get the file type
|
44
|
-
fileType = File.extname($testSuiteFile)
|
45
|
-
|
46
|
-
if (fileType.casecmp(@XlsxFileNameType) == 0)
|
47
|
-
XlsxParser.parse_xlxs_test_suite_data(testSpecIndex)
|
48
|
-
else
|
49
|
-
# the file type is not that expected so create a
|
50
|
-
# error message and raise an exception
|
51
|
-
error_to_display = "Test Suite file: '#{$testSuiteFile}' "\
|
52
|
-
"type not recognised (must be .xlsx)"
|
53
|
-
raise IOError, error_to_display
|
54
|
-
end
|
55
|
-
end
|
13
|
+
def self.test_files
|
14
|
+
@test_files ||= Dir.glob("#{$testcasesFolder}/*.xlsx").reject do |file|
|
15
|
+
File.basename(file).start_with?('~$')
|
16
|
+
end.sort
|
56
17
|
end
|
57
18
|
|
58
19
|
# readTestData
|
data/lib/parser/xlsx_parser.rb
CHANGED
@@ -7,53 +7,18 @@
|
|
7
7
|
# xlsx_parser.rb - xlsx parser functions
|
8
8
|
module XlsxParser
|
9
9
|
require_relative '../taf_config.rb'
|
10
|
-
def self.parse_xlxs_test_suite_header_data
|
11
|
-
begin
|
12
|
-
# get the number of test specifications in the file (number of
|
13
|
-
# occurences of "Test_Specification"
|
14
|
-
$numberOfTestSpecs = $XlsxSuiteDoc[0].sheet_data.size - 7
|
15
|
-
|
16
|
-
worksheet = $XlsxSuiteDoc[0]
|
17
|
-
$projectName = worksheet.sheet_data[1][0].value
|
18
|
-
$projectId = worksheet.sheet_data[1][1].value
|
19
|
-
$sprint = worksheet.sheet_data[1][2].value
|
20
|
-
|
21
|
-
$testSuiteId = worksheet.sheet_data[4][0].value
|
22
|
-
$testSuiteDes = worksheet.sheet_data[4][1].value
|
23
|
-
$tester = worksheet.sheet_data[4][2].value
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.parse_xlxs_test_suite_data(testSpecIndex)
|
28
|
-
worksheet = $XlsxSuiteDoc[0]
|
29
|
-
|
30
|
-
worksheet[7..$numberOfTestSpecs+7].map do |row|
|
31
|
-
suite = {
|
32
|
-
id: row[0].value,
|
33
|
-
specdesc: row[1].value,
|
34
|
-
env: row[3].value,
|
35
|
-
}
|
36
|
-
|
37
|
-
if ARGV.length < 2
|
38
|
-
suite[:browser] = row[2].value
|
39
|
-
elsif ARGV.length < 3
|
40
|
-
suite[:browser] = ARGV[1]
|
41
|
-
else
|
42
|
-
raise IOError, 'Unable to open browser'
|
43
|
-
end
|
44
|
-
|
45
|
-
suite
|
46
|
-
end
|
47
|
-
end
|
48
10
|
|
49
11
|
def self.parse_xlxs_test_header_data
|
50
12
|
# get the number of test steps in the file
|
51
|
-
$numberOfTestSteps = ($xlsxDoc[0].sheet_data.size) -
|
13
|
+
$numberOfTestSteps = ($xlsxDoc[0].sheet_data.size) - 4
|
52
14
|
worksheet = $xlsxDoc[0]
|
53
15
|
# get the remaining test data
|
54
|
-
$
|
16
|
+
$testId = worksheet.sheet_data[1][0].value
|
17
|
+
$projectId = worksheet.sheet_data[1][1].value
|
18
|
+
$testDes = worksheet.sheet_data[1][2].value
|
55
19
|
MyLog.log.info "Number of test steps: #{$numberOfTestSteps}"
|
56
20
|
MyLog.log.info "Test Description: #{$testDes}"
|
21
|
+
MyLog.log.info "TestID: #{$testId} \n"
|
57
22
|
|
58
23
|
end
|
59
24
|
|
@@ -61,7 +26,7 @@ module XlsxParser
|
|
61
26
|
def self.parse_test_step_data(testFileType)
|
62
27
|
begin
|
63
28
|
worksheet = $xlsxDoc[0]
|
64
|
-
worksheet[
|
29
|
+
worksheet[4..$numberOfTestSteps+4].map do |row|
|
65
30
|
test = {
|
66
31
|
testStep: row[0].value,
|
67
32
|
testdesc: row[1].value,
|
data/lib/report/junit_report.rb
CHANGED
@@ -28,8 +28,8 @@ module JunitReport
|
|
28
28
|
# output to XML file format for Junit for CI.
|
29
29
|
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
30
30
|
testsuite_attrs = {
|
31
|
-
'classname' => $
|
32
|
-
'name' => $
|
31
|
+
'classname' => $testcasesFolder.to_s,
|
32
|
+
'name' => $testcasesFolder.to_s,
|
33
33
|
'tests' => $totalTests.to_s,
|
34
34
|
'failures' => $totalTestFailures.to_s,
|
35
35
|
'timestamp' => $test_start_time.to_s,
|
@@ -14,10 +14,9 @@ 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
|
@testStepReportSummary[test_file_name_index] = <<~TEXT
|
17
|
-
Test file: #{test_file_name}
|
18
|
-
Browser type: #{$browserType}
|
17
|
+
Test file executed: #{test_file_name}
|
18
|
+
Browser type used: #{$browserType}
|
19
19
|
Browser version: #{Browser.browser_version}
|
20
|
-
Environment: #{$env_type}
|
21
20
|
Started at: #{$test_case_start_time}
|
22
21
|
Finished at: #{$test_case_end_time}
|
23
22
|
There are: #{$testStepPasses} Passes
|
@@ -30,7 +29,7 @@ module ReportSummary
|
|
30
29
|
def self.print_overall_test_summary
|
31
30
|
# output to the console
|
32
31
|
|
33
|
-
MyLog.log.info "Finished processing all test files - executed via test suite: #{$
|
32
|
+
MyLog.log.info "Finished processing all test files - executed via test suite: #{$testcasesFolder}"
|
34
33
|
MyLog.log.info "Overall Test Summary:"
|
35
34
|
@testStepReportSummary.each do |testStepReportSummary|
|
36
35
|
testStepReportSummary.each_line do |line|
|
data/lib/utils/browser.rb
CHANGED
@@ -113,14 +113,16 @@ module Browser
|
|
113
113
|
|
114
114
|
# create screenshot filename and save the screenshot if the test has failed or
|
115
115
|
# if explictly required
|
116
|
-
def self.check_save_screenshot(
|
116
|
+
def self.check_save_screenshot(screen_shot)
|
117
117
|
if ($currentTestFail || screen_shot)
|
118
118
|
time = Time.now.strftime('%H%M')
|
119
119
|
if ($currentTestFail)
|
120
|
+
full_sc_dirname = CreateDirectories.construct_testspecdirs
|
120
121
|
scFileName = full_sc_dirname + "/Test_step-#{$testStep}_Failed_"\
|
121
122
|
"#{time}.png"
|
122
123
|
else
|
123
124
|
# file name will be teststep.png
|
125
|
+
full_sc_dirname = CreateDirectories.construct_testspecdirs
|
124
126
|
scFileName = full_sc_dirname + "/Test_step-#{$testStep}_#{time}.png"
|
125
127
|
end
|
126
128
|
|
@@ -29,18 +29,25 @@ module CreateDirectories
|
|
29
29
|
|
30
30
|
# create the 'Project' directory if it doesn't already exist
|
31
31
|
project_id = $projectId.delete(' ')
|
32
|
-
project_iddir = result_home + '/' + project_id
|
33
|
-
Dir.mkdir(project_iddir) unless File.directory? project_iddir
|
32
|
+
$project_iddir = result_home + '/' + project_id
|
33
|
+
Dir.mkdir($project_iddir) unless File.directory? $project_iddir
|
34
34
|
|
35
|
-
#
|
35
|
+
# the test suite summary is a XML report generated will be called 'suite_summary.xml'
|
36
36
|
time = Time.new
|
37
37
|
f_date = time.strftime('%d-%b-%Y')
|
38
38
|
f_time = time.strftime('%H_%M_%S')
|
39
|
-
|
40
|
-
|
39
|
+
|
40
|
+
$TestSuiteSummaryXML = 'Results/' + $projectId + '/' + f_date + '_' + f_time + '_test_result.xml'
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.construct_testspecdirs
|
44
|
+
|
45
|
+
time = Time.new
|
46
|
+
f_date = time.strftime('%d-%b-%Y')
|
47
|
+
f_time = time.strftime('%H_%M_%S')
|
48
|
+
$runNoDir = $project_iddir + '/' + 'Ran_on_' + f_date + '_' + f_time
|
49
|
+
Dir.mkdir($runNoDir)
|
50
|
+
|
44
51
|
# create directories for each test spec
|
45
52
|
# create a sub-directory named from the 'testId' (with any spaces taken out)
|
46
53
|
# if it doesn't already exist plus the browser type
|
@@ -55,18 +62,6 @@ module CreateDirectories
|
|
55
62
|
abs_path_screenshot_dir = File.absolute_path(screenshot_dir)
|
56
63
|
abs_path_run_no_dir = File.absolute_path($runNoDir)
|
57
64
|
|
58
|
-
# the test suite summary is a XML report generated will be called 'suite_summary.xml'
|
59
|
-
time = Time.new
|
60
|
-
f_date = time.strftime('%d-%b-%Y')
|
61
|
-
f_time = time.strftime('%H_%M_%S')
|
62
|
-
|
63
|
-
$TestSuiteSummaryXML = 'Results/' + $projectId + '/' + f_date + '_' + f_time + '_test_result.xml'
|
64
|
-
|
65
|
-
# the log file name will be under the test ID directory
|
66
|
-
|
67
|
-
MyLog.log.info "TestId: #{$testId}"
|
68
|
-
MyLog.log.info "Screenshot directory: #{abs_path_screenshot_dir} \n"
|
69
|
-
|
70
65
|
# if any issues then set error message and re-raise the exception
|
71
66
|
rescue Exception => error
|
72
67
|
# construct the error message from custom text and the actual system error message (converted to a string)
|
data/lib/utils/test_engine.rb
CHANGED
@@ -12,114 +12,70 @@ module TestEngine
|
|
12
12
|
|
13
13
|
# process the test files to execute the tests
|
14
14
|
def self.process_testfiles
|
15
|
-
test_file_name = ''
|
16
|
-
|
17
|
-
# initialise the index for reading the list of test file names
|
18
|
-
test_file_name_index = 0
|
19
|
-
|
20
15
|
# get the overall test start time
|
21
16
|
$test_start_time = Report.current_time
|
22
17
|
|
23
|
-
# create project folders - these only need creating once per test suite
|
24
|
-
CreateDirectories.construct_projectdirs
|
25
|
-
|
26
18
|
# loop through all the available test files to execute the tests
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
begin # start of rescue block for construct_projectdirs
|
63
|
-
# create test spec directories - these need creating once per testspec
|
64
|
-
full_sc_dirname = CreateDirectories.construct_testspecdirs
|
65
|
-
# if an error then show the error and terminate
|
66
|
-
rescue StandardError => error
|
67
|
-
warn error
|
68
|
-
MyLog.log.warn error
|
69
|
-
abort
|
70
|
-
end
|
71
|
-
|
72
|
-
# loop through the test file
|
73
|
-
if testFileType != 'XLSX'
|
74
|
-
MyLog.log.info 'Not a valid XLSX File Type'
|
19
|
+
Parser.test_files.each_with_index do |test_file_name, test_file_index|
|
20
|
+
begin # start of rescue block for readTestData
|
21
|
+
# read in the test data
|
22
|
+
testFileType = Parser.read_test_data(test_file_name)
|
23
|
+
# if unable to read the test data, show the error and move onto the
|
24
|
+
# next file (if there is one)
|
25
|
+
rescue StandardError => error
|
26
|
+
MyLog.log.warn 'Terminating the current test case: ' \
|
27
|
+
"#{test_file_name} #{error}"
|
28
|
+
MyLog.log.info '...continuing with the next test case (if there is one)'
|
29
|
+
end # of rescue block for readTestData
|
30
|
+
|
31
|
+
# create project folders - these only need creating once per test suite
|
32
|
+
CreateDirectories.construct_projectdirs
|
33
|
+
|
34
|
+
# loop through the test file
|
35
|
+
MyLog.log.info 'Not a valid XLSX File Type' if testFileType != 'XLSX'
|
36
|
+
|
37
|
+
# get the test case start time
|
38
|
+
$test_case_start_time = Report.current_time
|
39
|
+
# initialise the test end time
|
40
|
+
$test_case_end_time = Report.current_time
|
41
|
+
|
42
|
+
begin
|
43
|
+
test_steps = Parser.parse_test_step_data(testFileType)
|
44
|
+
|
45
|
+
test_steps.each_with_index do |test_step, step_index|
|
46
|
+
$testStep = test_step[:testStep]
|
47
|
+
$testStepDes = test_step[:testdesc]
|
48
|
+
screen_shot = test_step[:screenShotData]
|
49
|
+
|
50
|
+
# process the test step data
|
51
|
+
TestSteps.process_test_steps(test_file_name, step_index, test_step)
|
52
|
+
# see if screenshot required
|
53
|
+
Browser.check_save_screenshot(screen_shot)
|
75
54
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# initialise the test end time
|
80
|
-
$test_case_end_time = Report.current_time
|
81
|
-
|
82
|
-
begin
|
83
|
-
test_steps = Parser.parse_test_step_data(testFileType)
|
84
|
-
|
85
|
-
test_steps.each_with_index do |test_step, index|
|
86
|
-
$testStep = test_step[:testStep]
|
87
|
-
$testStepDes = test_step[:testdesc]
|
88
|
-
screen_shot = test_step[:screenShotData]
|
89
|
-
|
90
|
-
# process the test step data
|
91
|
-
TestSteps.process_test_steps(test_file_name, index, test_step)
|
92
|
-
# see if screenshot required
|
93
|
-
Browser.check_save_screenshot(full_sc_dirname, screen_shot)
|
94
|
-
end
|
95
|
-
rescue TafError => error
|
96
|
-
warn error
|
97
|
-
MyLog.log.warn error
|
98
|
-
end
|
99
|
-
|
100
|
-
# get the test case end time
|
101
|
-
$test_case_end_time = Report.current_time
|
102
|
-
|
103
|
-
# output the test results summary for the current test case,
|
104
|
-
# pass in the test file number to save the summary against it's testfile
|
105
|
-
ReportSummary.test_step_summary(test_file_name, test_file_name_index)
|
106
|
-
JunitReport.test_step_summary_xml(test_file_name, test_file_name_index)
|
107
|
-
|
108
|
-
# close the browser if created
|
109
|
-
Browser.b.quit
|
110
|
-
|
111
|
-
# increment loop counter to move onto next test file
|
112
|
-
test_file_name_index += 1
|
113
|
-
|
114
|
-
# record total passes and failures and reset the failure counters for
|
115
|
-
# the test steps
|
116
|
-
$totalTestPasses += $testStepPasses
|
117
|
-
$totalTestFailures += $testStepFailures
|
118
|
-
$totalTestNotrun += $testStepNotrun
|
119
|
-
$testStepPasses = 0
|
120
|
-
$testStepFailures = 0
|
121
|
-
$testStepNotrun = 0
|
55
|
+
rescue TafError => error
|
56
|
+
warn error
|
57
|
+
MyLog.log.warn error
|
122
58
|
end
|
123
|
-
|
124
|
-
|
59
|
+
|
60
|
+
# get the test case end time
|
61
|
+
$test_case_end_time = Report.current_time
|
62
|
+
|
63
|
+
# output the test results summary for the current test case,
|
64
|
+
# pass in the test file number to save the summary against it's testfile
|
65
|
+
ReportSummary.test_step_summary(test_file_name, test_file_index)
|
66
|
+
JunitReport.test_step_summary_xml(test_file_name, test_file_index)
|
67
|
+
|
68
|
+
# close the browser if created
|
69
|
+
Browser.b.quit
|
70
|
+
|
71
|
+
# record total passes and failures and reset the failure counters for
|
72
|
+
# the test steps
|
73
|
+
$totalTestPasses += $testStepPasses
|
74
|
+
$totalTestFailures += $testStepFailures
|
75
|
+
$totalTestNotrun += $testStepNotrun
|
76
|
+
$testStepPasses = 0
|
77
|
+
$testStepFailures = 0
|
78
|
+
$testStepNotrun = 0
|
79
|
+
end
|
80
|
+
end # while loop for test files
|
125
81
|
end
|
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.
|
4
|
+
version: 0.2.0
|
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-03-
|
11
|
+
date: 2019-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|