Skip to content

Commit

Permalink
[ISSUE-cucumber#1044] Updates to support retry success status code 0
Browse files Browse the repository at this point in the history
-  Updated configuration to count the base number of cases being run
-  Updated failure? method to use cases.total_passed and total_cases to determine if the run was successful
  • Loading branch information
Brad Wedell authored and gondalez committed Jun 13, 2017
1 parent 3277793 commit 23e2b9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/cucumber/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def self.default
# @method on_event
def_instance_delegator :event_bus, :on, :on_event

attr_writer :total_cases

# @private
def notify(message, *args)
event_bus.send(message, *args)
Expand Down Expand Up @@ -67,6 +69,10 @@ def retry_attempts
@options[:retry]
end

def total_cases
@total_cases ||= 0
end

def guess?
@options[:guess]
end
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/filters/retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Filters
class Retry < Core::Filter.new(:configuration)

def test_case(test_case)
configuration.total_cases += 1
configuration.on_event(:test_case_finished) do |event|
next unless retry_required?(test_case, event)

Expand Down
3 changes: 3 additions & 0 deletions lib/cucumber/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def legacy_formatter?(factory)
def failure?
if @configuration.wip?
summary_report.test_cases.total_passed > 0
elsif @configuration.retry_attempts > 0
summary_report.test_cases.total_passed != @configuration.total_cases
else
summary_report.test_cases.total_failed > 0 || summary_report.test_steps.total_failed > 0 ||
(@configuration.strict? && (summary_report.test_steps.total_undefined > 0 || summary_report.test_steps.total_pending > 0))
Expand All @@ -248,6 +250,7 @@ def filters
filters << Cucumber::Core::Test::LocationsFilter.new(filespecs.locations)
filters << Filters::Randomizer.new(@configuration.seed) if @configuration.randomize?
filters << Filters::Quit.new

filters << Filters::Retry.new(@configuration)
# TODO: can we just use RbLanguages's step definitions directly?
step_match_search = StepMatchSearch.new(@support_code.ruby.method(:step_matches), @configuration)
Expand Down

0 comments on commit 23e2b9e

Please sign in to comment.