class Cutest::Reporter
Constants
- VERSION
Attributes
results[R]
Public Class Methods
new()
click to toggle source
# File lib/cutest/reporter.rb, line 11 def initialize @results = [] end
Public Instance Methods
record(name, state, exception = nil)
click to toggle source
Store test result
# File lib/cutest/reporter.rb, line 16 def record name, state, exception = nil results.push(Result.new(name, state, exception)) print display(state) end
report()
click to toggle source
Output summary report
# File lib/cutest/reporter.rb, line 22 def report successed = results.select(&:successed?) failed = results.select(&:failed?) skipped = results.select(&:skipped?) puts puts "#{results.count} tests" puts "#{successed.count} successed" puts "#{failed.count} failed" puts "#{skipped.count} skipped" display_result_trace(failed, "Failed:") if failed.count > 0 display_result_trace(skipped, "Skipped:") if skipped.count > 0 end
Private Instance Methods
display(state)
click to toggle source
# File lib/cutest/reporter.rb, line 47 def display state case state when "successed" "." when "failed" "F" when "skipped" "S" end end
display_result_trace(results, header)
click to toggle source
# File lib/cutest/reporter.rb, line 39 def display_result_trace(results, header) puts header results.each do |result| puts "test: #{result.name}" result&.exception&.backtrace&.each { |line| Cutest.display_trace(line) } end end