Skip to content

Commit

Permalink
Do not apply the hooks several time when using the retry option
Browse files Browse the repository at this point in the history
The test case received in the test_case_finished event might be equal
to the test case received from the previous filter when comparing with
'==', but it has the hooks applied to it so it cannot be passed on to
the next filter. Fixes #1098.
  • Loading branch information
brasmusson committed Mar 30, 2017
1 parent f52b6bc commit 31968ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Bugfixes

* Do not apply the hooks to the test case several times when using the retry option ([#1098](https://github.com/cucumber/cucumber-ruby/issues/1098) @brasmusson)
* Fix bug in comparing empty data tables ([#1097](https://github.com/cucumber/cucumber-ruby/pulls/1097), resolves [#1096](https://github.com/cucumber/cucumber-ruby/issues/1096))
* Configure Gemfile to fetch cucumber-ruby-wire from git if the repo is not found locally ([#983](https://github.com/cucumber/cucumber-ruby/pulls/983), resolves [#961](https://github.com/cucumber/cucumber-ruby/issues/961))
* Fix regression displaying CLI help ([#991](https://github.com/cucumber/cucumber-ruby/pull/991) @mattwynne)
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/filters/retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_case(test_case)
next unless retry_required?(test_case, event)

test_case_counts[test_case] += 1
event.test_case.describe_to(receiver)
test_case.describe_to(receiver)
end

super
Expand Down
13 changes: 13 additions & 0 deletions spec/cucumber/filters/retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@
end
end

context 'when performing retry' do
let(:result) { Cucumber::Core::Test::Result::Failed.new(0, StandardError.new) }

it 'describes the same test case object each time' do
allow(receiver).to receive(:test_case) {|tc|
expect(tc).to equal(test_case)
configuration.notify :test_case_finished, tc.with_steps(tc.test_steps), result
}

filter.test_case(test_case)
end
end

context 'consistently failing test case' do
let(:result) { Cucumber::Core::Test::Result::Failed.new(0, StandardError.new) }

Expand Down

1 comment on commit 31968ae

@mattwynne
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch Björn!

Please sign in to comment.