Module: TestEngine
- Defined in:
- lib/utils/test_engine.rb
Overview
Created on 20 Sept 2017 @author: Andy Perrett
Versions: 1.0 - Baseline
test_engine.rb - controls the iteration through the test suite and specs
Class Method Summary collapse
-
.process_testfiles ⇒ Object
process the test files to execute the tests.
Class Method Details
.process_testfiles ⇒ Object
process the test files to execute the tests
14 15 16 17 18 19 20 21 22 23 24 25 26 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/utils/test_engine.rb', line 14 def self.process_testfiles test_file_name = '' # initialise the index for reading the list of test file names test_file_name_index = 0 # get the overall test start time $test_start_time = Report.current_time # create project folders - these only need creating once per test suite CreateDirectories.construct_projectdirs # loop through all the available test files to execute the tests while test_file_name_index < $numberOfTestSpecs # get the next test spec data from the test suite doc test_suites = Parser.parse_test_suite_data(test_file_name_index) test_suites.each do |test_suite| $testId = test_suite[:id] $testSpecDesc = test_suite[:specdesc] $env_type = test_suite[:env] $browserType = test_suite[:browser] $securityTest = test_suite[:securitytest] if ARGV.length < 2 $browserType = test_suite[:browser] $securityTest = test_suite[:securitytest] puts '' puts "Will use the following browser from Test Suite: #{$browserType}" puts '' elsif ARGV.length < 3 $browserType = ARGV[1] $securityTest = ARGV[2] puts "\nWill use the following browser from CMD line: " + ARGV[1] puts '' elsif ARGV.length < 4 $securityTest = ARGV[2] puts "\nWill use the following browser from CMD line: " + ARGV[2] puts '' else raise IOError, 'Unable to open browser' end # if ARGV.length < 2 # $browserType = test_suite[:browser] # puts '' # puts "Will use the following browser from Test Suite: #{$browserType}" # puts '' # elsif ARGV.length < 3 # $browserType = ARGV[1] # puts "\nWill use the following browser from CMD line: " + ARGV[1] # puts '' # else # raise IOError, 'Unable to open browser' # end # remove any unwanted end-of-line characters from the file name test_file_name = $testSpecDesc begin # start of rescue block for readTestData # read in the test data testFileType = Parser.read_test_data(test_file_name) # if unable to read the test data, show the error and move onto the # next file (if there is one) rescue StandardError => error $stderr.puts "Terminating the current test case: " \ "#{test_file_name} #{error}" $stderr.puts '...continuing with the next test case (if there is one)' end # of rescue block for readTestData # create the project directories, returns the screenshot directory name begin # start of rescue block for construct_projectdirs # create test spec directories - these need creating once per testspec full_sc_dirname = CreateDirectories.construct_testspecdirs # open the log file Report.open_log_file # if an error then show the error and terminate rescue StandardError => error warn error $stdout.puts error abort end # open the test results output file Report.open_test_report_file # print the main test header Report.print_test_header # loop through the test file if testFileType != 'XLSX' puts 'Not a valid XLSX File Type' end Report.results.puts("Number of test steps: #{$numberOfTestSteps}") # get the test case start time $test_case_start_time = Report.current_time # initialise the test end time $test_case_end_time = Report.current_time begin test_steps = Parser.parse_test_step_data(testFileType) test_steps.each_with_index do |test_step, index| $testStep = test_step[:testStep] $testStepDes = test_step[:testdesc] screen_shot = test_step[:screenShotData] # process the test step data TestSteps.process_test_steps(test_file_name, index, test_step) # see if screenshot required Browser.check_save_screenshot(full_sc_dirname, screen_shot) end rescue TafError => error warn error $log.puts error end # get the test case end time $test_case_end_time = Report.current_time # output the test results summary for the current test case, # pass in the test file number to save the summary against it's testfile ReportSummary.test_step_summary(test_file_name, test_file_name_index) JunitReport.test_step_summary_xml(test_file_name, test_file_name_index) # close the test results file for the current test case Report.close_test_results_file # close the log file Report.close_log_file # close the browser if created Browser.b.quit # increment loop counter to move onto next test file test_file_name_index += 1 # record total passes and failures and reset the failure counters for # the test steps $totalTestPasses += $testStepPasses $totalTestFailures += $testStepFailures $totalTestNotrun += $testStepNotrun $testStepPasses = 0 $testStepFailures = 0 $testStepNotrun = 0 end end # while loop for test files end |