Class: TestFile

Inherits:
Object
  • Object
show all
Defined in:
lib/test_file.rb

Overview

A single Test File, might have multiple tests.

Instance Method Summary collapse

Constructor Details

#initialize(engine, path_name) ⇒ TestFile

Set up the test file.



9
10
11
12
13
14
# File 'lib/test_file.rb', line 9

def initialize( engine, path_name )
  @engine = engine
  @path_name = path_name

  @tests = []
end

Instance Method Details

#run_tests(results) ⇒ Object

Execute all tests in this file and add results to the overall test results.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/test_file.rb', line 20

def run_tests( results )
  # Load the test file
  @engine.persist_man.load( @path_name )
  # @engine.parser.run '.'

  # Find all Test objects in the loaded file(s)
  # The loaded file might have loaded other files
  @tests = Gloo::Core::ObjFinder.by_type( @engine, 'test' )

  # randomize the tests
  @tests.shuffle!

  # For each Test object, run its on_test script
  @tests.each do |o|
    result = o.run_test
    results.add_result result
  end

  # Collect results from each test

  # Aggregate result from test into overall results

  # file.show_info
end

#show_infoObject



52
53
54
# File 'lib/test_file.rb', line 52

def show_info
  puts "Test file: #{@path_name}"
end

#tests_run_countObject

Get the number of tests run.



48
49
50
# File 'lib/test_file.rb', line 48

def tests_run_count
  return @tests.length
end