mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Implement fail-fast in runner
Report tracks number of omitted tests due to abort.
This commit is contained in:
parent
9e63c20df2
commit
a31d5c8b5b
4 changed files with 82 additions and 7 deletions
|
@ -1,9 +1,10 @@
|
|||
require "./spec_helper"
|
||||
|
||||
# Creates a `Config` for Spectator that is suited for testing it.
|
||||
def spectator_test_config(formatter : Spectator::Formatting::Formatter? = nil)
|
||||
def spectator_test_config(formatter : Spectator::Formatting::Formatter? = nil, fail_fast = false)
|
||||
builder = Spectator::ConfigBuilder.new
|
||||
builder.formatter = formatter || Spectator::Formatting::SilentFormatter.new
|
||||
builder.fail_fast = fail_fast
|
||||
builder.build
|
||||
end
|
||||
|
||||
|
@ -26,6 +27,34 @@ describe Spectator::Runner do
|
|||
called.should eq([0, 1, 2, 3, 4])
|
||||
end
|
||||
|
||||
context "with fail-fast enabled" do
|
||||
it "stops on the first failure" do
|
||||
called = [] of Int32
|
||||
group = SpyExample.create_group(10) do |index|
|
||||
called << index
|
||||
raise "Failure" if index > 5
|
||||
end
|
||||
suite = Spectator::TestSuite.new(group)
|
||||
runner = Spectator::Runner.new(suite, spectator_test_config(fail_fast: true))
|
||||
runner.run
|
||||
called.should eq([0, 1, 2, 3, 4, 5, 6])
|
||||
end
|
||||
|
||||
context "the report" do
|
||||
it "has the remaining tests" do
|
||||
spy = SpyFormatter.new
|
||||
group = SpyExample.create_group(10) do |index|
|
||||
raise "Failure" if index > 5
|
||||
end
|
||||
suite = Spectator::TestSuite.new(group)
|
||||
runner = Spectator::Runner.new(suite, spectator_test_config(spy, true))
|
||||
runner.run
|
||||
report = spy.end_suite_calls.first
|
||||
report.remaining_count.should eq(3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "the formatter" do
|
||||
it "#start_suite is called once" do
|
||||
spy = SpyFormatter.new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue