class Assertor::Reporter
Attributes
case_list[R]
io[R]
Public Class Methods
new(io=$stdout, case_list=Assertor::Case.all)
click to toggle source
# File lib/assertor/reporter.rb, line 7 def initialize(io=$stdout, case_list=Assertor::Case.all) @io = io @case_list = case_list @passed, @failed, @errors, @exceptions = [],[],[],{} end
Public Instance Methods
run()
click to toggle source
# File lib/assertor/reporter.rb, line 14 def run calculate_results print_counters print_tests_with_exceptions(@failed, 'Failed') print_tests_with_exceptions(@errors, 'Error') end
Private Instance Methods
add_case_name_to_tests(test_case, tests)
click to toggle source
# File lib/assertor/reporter.rb, line 38 def add_case_name_to_tests(test_case, tests) tests.collect{ |test| "#{test_case}.#{test}" } end
add_test_results(test_case, results)
click to toggle source
# File lib/assertor/reporter.rb, line 29 def add_test_results(test_case, results) @passed += add_case_name_to_tests(test_case, results[:passed]) @failed += add_case_name_to_tests(test_case, results[:failed]) @errors += add_case_name_to_tests(test_case, results[:errors]) results[:exceptions].each do |test, exception| @exceptions["#{test_case}.#{test}"] = exception end end
calculate_results()
click to toggle source
# File lib/assertor/reporter.rb, line 23 def calculate_results Assertor::Case.run_all(@case_list).each do |test_case, results| add_test_results(test_case, results) end end
print_counters()
click to toggle source
# File lib/assertor/reporter.rb, line 42 def print_counters @io.puts("passed: #{@passed.size} failed: #{@failed.size} errors: #{@errors.size}") end
print_tests_with_exceptions(tests, type)
click to toggle source
# File lib/assertor/reporter.rb, line 46 def print_tests_with_exceptions(tests, type) tests.each do |t| exception = @exceptions[t] @io.puts @io.puts "#{type}: #{t}" @io.puts " #{exception.inspect}" @io.print " " @io.puts exception.backtrace.join("\n ") end end