Skip to content

Commit

Permalink
Add console summary method for printing Minitest results to console (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
noahgibbs authored Mar 24, 2024
1 parent add38b2 commit 13819ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scarpe-components/lib/scarpe/components/minitest_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def result_and_message
["success", "OK"]
end

def console_summary
return "Error(s): #{@exceptions.inspect}" if self.error?
return "Failure: #{@failures.inspect}" if self.fail?
return "Skip: #{skip_message.inspect}" if self.skip?
"Success!"
end

def check(expect_result: :success, min_asserts: nil, max_asserts: nil)
unless [:error, :fail, :skip, :success].include?(expect_result)
raise Scarpe::InternalError, "Expected test result should be one of [:success, :fail, :error, :skip]!"
Expand Down
7 changes: 7 additions & 0 deletions scarpe-components/test/test_minitest_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ def test_mtr_skip_w_msg
refute res.passed?
assert_equal "Just skipping", res.skip_message
end

def test_mtr_console_summary
path = File.join __dir__, "mtr_data/skipped_w_msg.json"
res = Scarpe::Components::MinitestResult.new(path)

assert res.console_summary.include?("Skip:")
end
end

0 comments on commit 13819ff

Please sign in to comment.