diff --git a/README.md b/README.md index 97ee7e5..6e525e8 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ In no particular order, features that have been implemented and are planned: - [ ] Misc. matchers - `exist`, `match`, `satisfy`, `change[.by|.from[.to]|.to|.by_at_least|.by_at_most]`, `have_attributes` - [ ] Expectation combining - `and`, `or` - [ ] Runner - - [ ] Fail fast + - [X] Fail fast - [ ] Test filtering - by name, context, and tags - [ ] Fail on no tests - [ ] Randomize test order diff --git a/src/spectator/formatting/remaining_text.cr b/src/spectator/formatting/remaining_text.cr new file mode 100644 index 0000000..b3639ec --- /dev/null +++ b/src/spectator/formatting/remaining_text.cr @@ -0,0 +1,15 @@ +module Spectator::Formatting + # Text displayed when fail-fast is enabled and tests were skipped. + private struct RemainingText + # Creates the text object. + def initialize(@count : Int32) + end + + # Appends the command to the output. + def to_s(io) + io << "Text execution aborted (fail-fast) - " + io << @count + io << " examples were omitted." + end + end +end diff --git a/src/spectator/formatting/suite_summary.cr b/src/spectator/formatting/suite_summary.cr index 42d5b36..9eceac3 100644 --- a/src/spectator/formatting/suite_summary.cr +++ b/src/spectator/formatting/suite_summary.cr @@ -14,6 +14,7 @@ module Spectator::Formatting @io.puts failures(report.failures) if report.failed? stats(report) + remaining(report) if report.remaining? failure_commands(report.failures) if report.failed? end @@ -35,6 +36,12 @@ module Spectator::Formatting @io.puts StatsCounter.new(report).color end + # Produces the skipped tests text if fail-fast is enabled and tests were omitted. + private def remaining(report) + text = RemainingText.new(report.remaining_count) + @io.puts Color.failure(text) + end + # Produces the failure commands section of the summary. # This provides a set of commands the user can run # to test just the examples that failed.