Class: SqlTestRunner::TestResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ TestResult

Returns a new instance of TestResult.



57
58
59
60
61
# File 'lib/sql_test_runner.rb', line 57

def initialize(logger)
  @logger = logger
  @errors = []
  @steps_count = 0
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



89
90
91
# File 'lib/sql_test_runner.rb', line 89

def errors
  @errors
end

#loggerObject (readonly)

Returns the value of attribute logger.



89
90
91
# File 'lib/sql_test_runner.rb', line 89

def logger
  @logger
end

Instance Method Details

#error_countObject



75
76
77
# File 'lib/sql_test_runner.rb', line 75

def error_count
  @errors.size
end

#log_error(error) ⇒ Object



69
70
71
72
73
# File 'lib/sql_test_runner.rb', line 69

def log_error(error)
  error = ExpectationNotMetError.new(error, @last_step)
  logger.log_error(error)
  @errors << error
end

#log_resultsObject



79
80
81
# File 'lib/sql_test_runner.rb', line 79

def log_results
  logger.log_results(self)
end

#log_step(step) ⇒ Object



63
64
65
66
67
# File 'lib/sql_test_runner.rb', line 63

def log_step(step)
  @last_step = step
  @steps_count += 1
  logger.log_step(step)
end

#summaryObject



83
84
85
86
87
# File 'lib/sql_test_runner.rb', line 83

def summary
  lines = errors.map { |error| error.summary }
  lines << "#{@steps_count} testcases - #{error_count} failures"
  lines.join $/
end