diff --git a/src/spectator/core/runner.cr b/src/spectator/core/runner.cr index bd34676b..476b985d 100644 --- a/src/spectator/core/runner.cr +++ b/src/spectator/core/runner.cr @@ -13,25 +13,19 @@ module Spectator def run(spec : ExampleGroup) report &.started report &.suite_started - failures = [] of ExecutionResult - pending = [] of ExecutionResult - examples_to_run(spec).each do |example| - if (group = example.group) && group.no_runs? - report &.example_group_started(group) + results = + examples_to_run(spec).map do |example| + if (group = example.group) && group.no_runs? + report &.example_group_started(group) + end + result = run_example(example) + if (group = example.group) && group.run? + report &.example_group_finished(group) + end + result end - result = run_example(example) - if result.failed? - failures << result - elsif result.skipped? - pending << result - end - if (group = example.group) && group.run? - report &.example_group_finished(group) - end - end report &.suite_finished - report &.report_failures(failures) unless failures.empty? - report &.report_pending(pending) unless pending.empty? + report &.report_results(results) report &.report_profile report &.report_summary report &.report_post_summary diff --git a/src/spectator/formatters/common_text_output.cr b/src/spectator/formatters/common_text_output.cr index 1f38fe2e..75dfcd5a 100644 --- a/src/spectator/formatters/common_text_output.cr +++ b/src/spectator/formatters/common_text_output.cr @@ -4,7 +4,14 @@ require "../core/source_cache" module Spectator::Formatters module CommonTextOutput - def report_failures(results : Enumerable(Core::ExecutionResult)) : Nil + def report_results(results : Enumerable(Core::ExecutionResult)) : Nil + failures = results.select &.failed? + report_failures(failures) unless failures.empty? + skipped = results.select &.skipped? + report_skipped(skipped) unless skipped.empty? + end + + private def report_failures(results : Enumerable(Core::ExecutionResult)) : Nil puts puts "Failures:" puts @@ -83,17 +90,17 @@ module Spectator::Formatters end end - def report_pending(results : Enumerable(Core::ExecutionResult)) : Nil + private def report_skipped(results : Enumerable(Core::ExecutionResult)) : Nil puts - puts "Pending:" + puts "Skipped:" puts padding = results.size.to_s.size - 1 # -1 since the minimum width is 1. results.each_with_index(1) do |result, index| - print_pending(result, index, padding) + print_skipped(result, index, padding) end end - private def print_pending(result, number, padding) : Nil + private def print_skipped(result, number, padding) : Nil end def report_profile : Nil diff --git a/src/spectator/formatters/compatible_junit_formatter.cr b/src/spectator/formatters/compatible_junit_formatter.cr index 97e0b9b0..d50829f6 100644 --- a/src/spectator/formatters/compatible_junit_formatter.cr +++ b/src/spectator/formatters/compatible_junit_formatter.cr @@ -94,10 +94,7 @@ module Spectator::Formatters parts.join('.') end - def report_failures(results : Enumerable(Core::ExecutionResult)) : Nil - end - - def report_pending(results : Enumerable(Core::ExecutionResult)) : Nil + def report_results(results : Enumerable(Core::ExecutionResult)) : Nil end def report_profile : Nil diff --git a/src/spectator/formatters/formatter.cr b/src/spectator/formatters/formatter.cr index 452cd0cf..cb2740f7 100644 --- a/src/spectator/formatters/formatter.cr +++ b/src/spectator/formatters/formatter.cr @@ -23,9 +23,7 @@ module Spectator::Formatters abstract def example_finished(result : Core::ExecutionResult) : Nil - abstract def report_failures(results : Enumerable(Core::ExecutionResult)) : Nil - - abstract def report_pending(results : Enumerable(Core::ExecutionResult)) : Nil + abstract def report_results(results : Enumerable(Core::ExecutionResult)) : Nil abstract def report_profile : Nil