diff --git a/src/spectator/formatters/default_formatter.cr b/src/spectator/formatters/default_formatter.cr index d623978..5de8d36 100644 --- a/src/spectator/formatters/default_formatter.cr +++ b/src/spectator/formatters/default_formatter.cr @@ -9,6 +9,9 @@ module Spectator def end_suite(results : TestResults) puts + puts + puts finish_time_string(results) + puts result_string(results) end def start_example(example : Example) @@ -26,6 +29,22 @@ module Spectator "F".colorize.red end end + + private def finish_time_string(results) + "Finished in #{human_time(results.runtime)}" + end + + private def result_string(results) + examples = results.examples + failures = results.failed_examples + errors = results.errored_examples + pending = results.pending_examples + "#{examples} examples, #{failures} failures, #{errors} errors, #{pending} pending" + end + + private def human_time(span : Time::Span) + span.to_s + end end end end diff --git a/src/spectator/test_results.cr b/src/spectator/test_results.cr index 0c05b0b..5ff41cc 100644 --- a/src/spectator/test_results.cr +++ b/src/spectator/test_results.cr @@ -8,12 +8,24 @@ module Spectator @results = results.to_a end + def examples + @results.size + end + def successful_examples - @results.select { |result| result.successful? } + @results.count(&.successful?) end def failed_examples - @results.select { |result| result.failed? } + @results.count(&.failed?) + end + + def errored_examples + @results.count(&.errored?) + end + + def pending_examples + @results.count(&.pending?) end def example_runtime