-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
483 additions
and
467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require "../spec_helper" | ||
|
||
describe Microtest::DescriptionReporter do | ||
test "description reporter" do | ||
result = record_test([Microtest::DescriptionReporter.new]) do | ||
describe DescriptionReporter do | ||
test "success" do | ||
assert true | ||
end | ||
|
||
test "failure" do | ||
assert 3 > 5 | ||
end | ||
|
||
test "error" do | ||
raise "unexpected" | ||
end | ||
|
||
test "skip" do | ||
skip "skip this one" | ||
end | ||
end | ||
end | ||
|
||
assert !result.success? | ||
|
||
# dot = Microtest::TerminalReporter::DOTS[:success] | ||
|
||
output = uncolor(result.stdout) | ||
assert output.includes?("DescriptionReporterTest") | ||
assert output.matches?(%r{ ✓\s+\d+ .s success}) | ||
assert output.matches?(%r{ ✕\s+\d+ .s error}) | ||
assert output.matches?(%r{ ✕\s+\d+ .s failure}) | ||
assert output.matches?(%r{ ✓\s+\d+ .s skip}) | ||
end | ||
|
||
test "description reporter abortion" do | ||
result = record_test([Microtest::DescriptionReporter.new]) do | ||
describe DescriptionReporter do | ||
before do | ||
raise "ABORTED" | ||
end | ||
|
||
test "failure" do | ||
assert false | ||
end | ||
end | ||
end | ||
|
||
assert !result.success? | ||
|
||
output = uncolor(result.stdout) | ||
|
||
assert output.includes?("DescriptionReporterTest") | ||
assert output.matches?(%r{ 💥\s+\d+ .s failure}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require "../spec_helper" | ||
|
||
describe Microtest::ErrorListReporter do | ||
test "error list reporter" do | ||
result = record_test([Microtest::ErrorListReporter.new]) do | ||
describe Microtest do | ||
test "success" do | ||
assert true | ||
end | ||
|
||
test "failure" do | ||
assert 3 > 5 | ||
end | ||
|
||
test "error" do | ||
raise "unexpected" | ||
end | ||
|
||
test "skip" do | ||
skip "skip this one" | ||
end | ||
end | ||
end | ||
|
||
assert !result.success? | ||
|
||
output = uncolor(result.stdout) | ||
|
||
assert output.matches?(%r{skip: skip this one in SPEC: spec/test.cr:16}) | ||
assert output.matches?(%r{# 1 MicrotestTest#error SPEC: spec/test.cr:12\nunexpected\n┏}) | ||
assert output.matches?(%r{# 2 MicrotestTest#failure SPEC: spec/test.cr:\d+\n◆ assert 3 > 5}) | ||
end | ||
|
||
test "error list reporter abortion" do | ||
result = record_test([Microtest::ErrorListReporter.new]) do | ||
describe Microtest do | ||
before do | ||
raise "ABORTED" | ||
end | ||
|
||
test "failure" do | ||
assert false | ||
end | ||
end | ||
end | ||
|
||
assert !result.success? | ||
|
||
output = uncolor(result.stdout) | ||
|
||
assert output.matches?(/ABORTED/) | ||
assert output.matches?(%r{┗ SPEC: spec/test.cr:\d+ before_hooks}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require "../spec_helper" | ||
|
||
describe Microtest::ProgressReporter do | ||
test "progress reporter" do | ||
result = record_test([Microtest::ProgressReporter.new]) do | ||
describe Microtest do | ||
test "success" do | ||
assert true | ||
end | ||
|
||
test "failure" do | ||
assert 3 > 5 | ||
end | ||
|
||
test "error" do | ||
raise "unexpected" | ||
end | ||
|
||
test "skip" do | ||
skip "skip this one" | ||
end | ||
end | ||
end | ||
|
||
assert !result.success? | ||
|
||
dot = Microtest::TerminalReporter::DOTS[:success] | ||
|
||
assert result.stdout == [ | ||
dot.colorize(:green), | ||
dot.colorize(:red), | ||
dot.colorize(:yellow), | ||
dot.colorize(:red), | ||
"\n\n", | ||
].join | ||
end | ||
|
||
test "progress reporter abortion" do | ||
result = record_test([Microtest::ProgressReporter.new]) do | ||
describe Microtest do | ||
before do | ||
raise "aborted" | ||
end | ||
|
||
test "failure" do | ||
assert false | ||
end | ||
end | ||
end | ||
|
||
assert !result.success? | ||
|
||
bang = Microtest::TerminalReporter::DOTS[:abortion] | ||
|
||
assert result.stdout.includes?(bang.colorize(:yellow).to_s) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require "../spec_helper" | ||
|
||
describe Microtest::SummaryReporter do | ||
test "summary reporter" do | ||
result = record_test([Microtest::SummaryReporter.new]) do | ||
describe Microtest do | ||
test "success" do | ||
assert true | ||
end | ||
|
||
test "failure" do | ||
assert 3 > 5 | ||
end | ||
|
||
test "skip" do | ||
skip "skip this one" | ||
end | ||
end | ||
end | ||
|
||
assert !result.success? | ||
|
||
output = uncolor(result.stdout) | ||
assert output.matches?(%r{Executed 3/3 tests in \d+µs with seed 1}) | ||
assert output.includes?("Success: 1, Skips: 1, Failures: 1") | ||
end | ||
|
||
test "summary reporter abortion" do | ||
result = record_test([Microtest::SummaryReporter.new]) do | ||
describe Microtest do | ||
before do | ||
raise "aborted" | ||
end | ||
|
||
test "failure" do | ||
assert false | ||
end | ||
end | ||
end | ||
|
||
assert !result.success? | ||
|
||
assert result.stdout.includes?("Test run was aborted by exception in hooks for \"failure\"") | ||
end | ||
end |
Oops, something went wrong.