mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Tests for nested groups and fail-fast
This commit is contained in:
parent
1d530de5b1
commit
00045ba9be
1 changed files with 45 additions and 0 deletions
|
@ -13,6 +13,18 @@ def new_test_suite(group : Spectator::ExampleGroup? = nil)
|
||||||
Spectator::TestSuite.new(group || PassingExample.create.group, filter)
|
Spectator::TestSuite.new(group || PassingExample.create.group, filter)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def suite_with_nested_failures(hooks)
|
||||||
|
conditions = Spectator::ExampleConditions.empty
|
||||||
|
values = Spectator::Internals::SampleValues.empty
|
||||||
|
root = Spectator::RootExampleGroup.new(hooks, conditions)
|
||||||
|
root.children = Array(Spectator::ExampleComponent).new(5) do |index|
|
||||||
|
Spectator::NestedExampleGroup.new(index.to_s, root, hooks, conditions).tap do |group|
|
||||||
|
group.children = Array(Spectator::ExampleComponent).new(5) { FailingExample.new(group, values) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
new_test_suite(root)
|
||||||
|
end
|
||||||
|
|
||||||
describe Spectator::Runner do
|
describe Spectator::Runner do
|
||||||
describe "#run" do
|
describe "#run" do
|
||||||
it "runs all examples in the suite" do
|
it "runs all examples in the suite" do
|
||||||
|
@ -74,6 +86,39 @@ describe Spectator::Runner do
|
||||||
called.should be_true
|
called.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with nested groups" do
|
||||||
|
it "runs after_each hooks" do
|
||||||
|
call_count = 0
|
||||||
|
hooks = new_hooks(after_each: ->{ call_count += 1; nil })
|
||||||
|
suite = suite_with_nested_failures(hooks)
|
||||||
|
runner = Spectator::Runner.new(suite, spectator_test_config(fail_fast: true))
|
||||||
|
runner.run
|
||||||
|
call_count.should eq(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "runs after_all hooks" do
|
||||||
|
call_count = 0
|
||||||
|
hooks = new_hooks(after_all: ->{ call_count += 1; nil })
|
||||||
|
suite = suite_with_nested_failures(hooks)
|
||||||
|
runner = Spectator::Runner.new(suite, spectator_test_config(fail_fast: true))
|
||||||
|
runner.run
|
||||||
|
call_count.should eq(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "runs the remaining around_each hook code" do
|
||||||
|
call_count = 0
|
||||||
|
hooks = new_hooks(around_each: ->(proc : ->) {
|
||||||
|
proc.call
|
||||||
|
call_count += 1
|
||||||
|
nil
|
||||||
|
})
|
||||||
|
suite = suite_with_nested_failures(hooks)
|
||||||
|
runner = Spectator::Runner.new(suite, spectator_test_config(fail_fast: true))
|
||||||
|
runner.run
|
||||||
|
call_count.should eq(2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "the report" do
|
context "the report" do
|
||||||
it "has the remaining tests" do
|
it "has the remaining tests" do
|
||||||
spy = SpyFormatter.new
|
spy = SpyFormatter.new
|
||||||
|
|
Loading…
Reference in a new issue