Module: Taf::TestEngine

Defined in:
lib/taf/test_engine.rb

Overview

test_engine.rb - controls the iteration through the test suite and specs

Class Method Summary collapse

Class Method Details

.process_testfilesObject

process the test files to execute the tests



13
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
# File 'lib/taf/test_engine.rb', line 13

def self.process_testfiles
  total_passes = 0
  total_failures = 0
  total_skipped = 0

  # loop through all the available test files to execute the tests
  Taf::Parser.test_files.each_with_index do |test_file_name, test_file_idx|
    metrics = Struct.new(:stepPasses, :stepFailures, :stepSkipped)
                    .new(0, 0, 0)

    begin
      # read in the test data
      tests = Taf::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 => e
      Taf::MyLog.log.warn 'Terminating the current test spec: ' \
                   "#{test_file_name} #{e}"
      Taf::MyLog.log.info
      '...continuing with the next test file (if there is one)'
    end

    # create project folders - these only need creating once per test suite
    Taf::CreateDirectories.construct_projectdirs

    Taf::Browser.open_browser

    begin
      tests['steps'].each_with_index do |test_step, test_step_idx|
        test_step_idx += 1

        parsed_steps = Taf::Parser.parse_test_step_data(test_step)

        # process the test step data
        Taf::TestSteps.process_test_steps(test_file_name, test_step_idx,
                                          parsed_steps, metrics)
      end
    rescue Taf::TafError => e
      warn e
      Taf::MyLog.log.warn e
    end

    # output the test results summary to console
    Taf::ReportSummary.test_step_summary(test_file_name, test_file_idx,
                                         metrics)

    # close the browser if created
    Taf::Browser.b.quit

    # record total passes and failures and reset the failure counters for
    # the test steps
    total_passes   += metrics.stepPasses
    total_failures += metrics.stepFailures
    total_skipped  += metrics.stepSkipped
  end

  [total_passes, total_failures, total_skipped]
end