Need help to write pending scenarios in rerun file

23 views
Skip to first unread message

Shyam Jakkampudi

unread,
Sep 12, 2017, 3:33:12 PM9/12/17
to Cukes

Hi,
The earlier versions of cucumber used to write both failure and pending scenarios in to rerun file but not anymore. Our tests mostly rely on the test data (program information) that changes every 30 mins and we have a shell script in place to rerun both failure and pending scenarios twice, which would eventually pass in the second or third attempt. Since, the rerun file is not writing any pending scenarios anymore, we have to manually identify those pending scenarios from 300-400 feature files and run them again, which is time consuming.

Can you please help me out with the changes that I need to make in the following file to make it work as per our project needs. Thanks much for your help in advance!

https://github.com/cucumber/cucumber-ruby/blob/master/lib/cucumber/formatter/rerun.rb


frozen_string_literal: true

require 'cucumber/formatter/io'

module Cucumber
module Formatter
class Rerun
include Formatter::Io

  def initialize(config)
    @io = ensure_io(config.out_stream)
    @config = config
    @failures = {}
    config.on_event :test_case_finished do |event|
        puts event
      test_case, result = *event.attributes
      puts result
      next if result.ok?(@config.strict?)
      @failures[test_case.location.file] ||= []
      @failures[test_case.location.file] << test_case.location.line
    end
    config.on_event :test_run_finished do
      next if @failures.empty?
      @io.print file_failures.join(' ')
    end
  end

  private

  def file_failures
    @failures.map { |file, lines| [file, lines].join(':') }
  end
end 
end 
end

Björn Rasmusson

unread,
Sep 13, 2017, 5:28:49 AM9/13/17
to Cukes
Shyam Jakkampudi wrote:

Hi,
The earlier versions of cucumber used to write both failure and pending scenarios in to rerun file but not anymore.


The scenarios written to the rerun file are the scenarios that each would make the exit code non-zero. Failed scenarios are alway changing the exit code to non-zero, that they are therefore always entered in the rerun file. Pending, Undefined, and Flaky scenarios are changing the exit code to non-zero depending on the --strict setting, which means that the --strict setting also controls whether these scenarios are written into the rerun file.


If you run Cucumber with the --strict option, then Pending, Undefined, and Flaky scenarios will be entered into the rerun file


/Björn
 
Reply all
Reply to author
Forward
0 new messages