From 31968ae09ae5ff8898cbc571ac9a932c98f0bbbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rasmusson?= Date: Thu, 30 Mar 2017 20:02:00 +0200 Subject: [PATCH] Do not apply the hooks several time when using the retry option 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. --- History.md | 1 + lib/cucumber/filters/retry.rb | 2 +- spec/cucumber/filters/retry_spec.rb | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index fa17dc7282..4444b35b4d 100644 --- a/History.md +++ b/History.md @@ -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) diff --git a/lib/cucumber/filters/retry.rb b/lib/cucumber/filters/retry.rb index cf5605533f..db4f63b0ee 100644 --- a/lib/cucumber/filters/retry.rb +++ b/lib/cucumber/filters/retry.rb @@ -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 diff --git a/spec/cucumber/filters/retry_spec.rb b/spec/cucumber/filters/retry_spec.rb index af002f098e..02272e7f69 100644 --- a/spec/cucumber/filters/retry_spec.rb +++ b/spec/cucumber/filters/retry_spec.rb @@ -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) }