Sha256: f43549a42b6d60183717148e657811db527c3da262beffbcd1fbe2550bbadad5

Contents?: true

Size: 789 Bytes

Versions: 5

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true
require 'cucumber/core/filter'
require 'cucumber/running_test_case'
require 'cucumber/events'

module Cucumber
  module Filters
    class Retry < Core::Filter.new(:configuration)

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

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

        super
      end

      private

      def retry_required?(test_case, event)
        event.test_case == test_case && event.result.failed? && test_case_counts[test_case] < configuration.retry_attempts
      end

      def test_case_counts
        @test_case_counts ||= Hash.new {|h,k| h[k] = 0 }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cucumber-3.1.0 lib/cucumber/filters/retry.rb
cucumber-3.0.2 lib/cucumber/filters/retry.rb
cucumber-3.0.1 lib/cucumber/filters/retry.rb
cucumber-3.0.0 lib/cucumber/filters/retry.rb
cucumber-3.0.0.pre.2 lib/cucumber/filters/retry.rb