Class: TestRunner

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

Overview

Test Runner.

Instance Method Summary collapse

Constructor Details

#initialize(engine, input_files = nil) ⇒ TestRunner

Set up the test runner.



10
11
12
13
14
15
16
17
# File 'lib/test_runner.rb', line 10

def initialize( engine, input_files = nil )
  @engine = engine

  @files = TestFiles.new( @engine, input_files )
  @results = Results.new( @engine )

  @engine.log.debug "TestRunner initialized"
end

Instance Method Details

#runObject

Execute all tests and display results.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/test_runner.rb', line 22

def run
  setup

  @results.start_timer    
  run_for_files
  @results.end_timer

  @results.show_failures
  @results.show_results
  @engine.log.debug "TestRunner is finished"
end

#run_for_filesObject

Run tests for each file.



52
53
54
55
56
57
# File 'lib/test_runner.rb', line 52

def run_for_files
  @files.each do |file|
    run_one_file( file )
  end
  puts
end

#run_one_file(file) ⇒ Object

Run tests for a single file. Once done, reset the engine's state.



63
64
65
66
67
68
69
70
# File 'lib/test_runner.rb', line 63

def run_one_file( file )
  # Run all tests in the file
  # Add the results to the overall results
  file.run_tests( @results )

  # Reset the engine's state
  @engine.reset_state
end

#setupObject

Set up the test runner.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/test_runner.rb', line 37

def setup
  @engine.log.debug "TestRunner is running…"
  puts
  puts "Gloo Test Runner".white
  puts

  # Get a list of test files and randomize
  @files.detect_files
  @results.file_count = @files.count
  @files.randomize
end