class Cucumber::Formatter::Rerun
Public Class Methods
Source
# File lib/cucumber/formatter/rerun.rb, line 12 def initialize(config) @config = config @io = ensure_io(config.out_stream, config.error_stream) @repository = Cucumber::Repository.new @query = Cucumber::Query.new(@repository) config.on_event :envelope, &method(:output_envelope) end
Public Instance Methods
Source
# File lib/cucumber/formatter/rerun.rb, line 20 def output_envelope(event) envelope = event.envelope @repository.update(envelope) finish_report if envelope.test_run_finished end
Private Instance Methods
Source
# File lib/cucumber/formatter/rerun.rb, line 79 def failure_array uri_and_location_hash.filter_map do |uri, lines| "#{uri}:#{lines.join(':')}" if lines.any? end end
Source
# File lib/cucumber/formatter/rerun.rb, line 28 def finish_report @query.find_all_test_case_started.each do |test_case| status = @query.find_most_severe_test_step_result_by(test_case).status # RULE: Don't log test cases without a pickle (Unsure what these could be?) pickle = @query.find_pickle_by(test_case) next if pickle.nil? # RULE: (Configuration specific) # -> If the test case has already been logged (And so we're retrying), we remove prior references of failures if passing?(test_case) && !rerun_flaky_tests? uri_and_location_hash[pickle.uri].delete(pickle.location.line) next end # RULE: (Configuration specific - to be amended once CCK conformance is finalised) # -> If the strict configuration permits the result - handle it accordingly if status == 'UNDEFINED' && !@config.strict.strict?(:undefined) Cucumber.deprecate( 'The strict configuration in cucumber is going away and moving towards a standardised set of behaviours', '--strict=undefined', '12.0.0' ) next end if status == 'PENDING' && !@config.strict.strict?(:pending) Cucumber.deprecate( 'The strict configuration in cucumber is going away and moving towards a standardised set of behaviours', '--strict=pending', '12.0.0' ) next end # RULE: Passing test cases are not considered failures (Don't log these) next if passing?(test_case) # RULE: Skipped test cases are not considered failures (on their own, don't log these) next if skipped?(test_case) # RULE: Before logging a failure, ensure we are not on a retried test case (Don't log a retry multiple times) next if test_case.attempt > 1 # Log the failure if every other skip rule has not been met, and the failure has not already been logged uri_and_location_hash[pickle.uri] << pickle.location.line end # Generate the final output from the logged failures to be formatted in the io output @io.print(failure_array.join("\n")) end
Source
# File lib/cucumber/formatter/rerun.rb, line 93 def passing?(test_case_started) most_severe_test_step_result = @query.find_most_severe_test_step_result_by(test_case_started) most_severe_test_step_result.status == Cucumber::Messages::TestStepResultStatus::PASSED end
Source
# File lib/cucumber/formatter/rerun.rb, line 89 def rerun_flaky_tests? @config.strict.strict?(:flaky) end
Source
# File lib/cucumber/formatter/rerun.rb, line 98 def skipped?(test_case_started) most_severe_test_step_result = @query.find_most_severe_test_step_result_by(test_case_started) most_severe_test_step_result.status == Cucumber::Messages::TestStepResultStatus::SKIPPED end
Source
# File lib/cucumber/formatter/rerun.rb, line 85 def uri_and_location_hash @uri_and_location_hash ||= Hash.new { |hash, key| hash[key] = Set.new } end