scenario_progress_formatter.rb revision bd4e9a285a601bd6f25781d30ebcd63642929fdd
427N/Arequire 'cucumber/formatter/progress'
427N/A
427N/Aclass ScenarioProgressFormatter < Cucumber::Formatter::Progress
427N/A SCENARIO_INDENT = 2
427N/A EXCEPTION_INDENT = SCENARIO_INDENT + 2
427N/A
427N/A def initialize(runtime, path_or_io, options)
427N/A super(runtime, path_or_io, options)
427N/A @failed_scenario_steps = []
427N/A @processed_steps = []
427N/A end
427N/A
427N/A def after_feature_element(feature_element)
427N/A super(feature_element)
427N/A @io.puts
427N/A @io.flush
427N/A end
427N/A
427N/A def before_feature_element(feature_element)
427N/A super(feature_element)
427N/A @processed_steps = [@current_feature]
427N/A @failed = false
3661N/A end
427N/A
427N/A def after_feature_element(feature_element)
427N/A @failed_scenario_steps << @processed_steps if @failed
427N/A super(feature_element)
427N/A @io.puts
427N/A @io.flush
618N/A end
427N/A
427N/A def after_background(background)
844N/A @io.puts
844N/A @io.flush
618N/A end
1273N/A
427N/A def before_steps(*_args)
3661N/A super(*_args)
3661N/A @io.print(' ')
427N/A @io.flush
427N/A end
427N/A
427N/A def tag_name(tag_name)
427N/A tag = format_string(tag_name, :tag).indent(SCENARIO_INDENT)
427N/A @processed_steps << tag
427N/A @io.puts(tag)
427N/A @io.flush
427N/A end
427N/A
427N/A def feature_name(keyword, name)
427N/A @current_feature = "Feature: #{name}"
427N/A @io.puts("#{keyword}: #{name}")
427N/A @io.flush
427N/A end
427N/A
427N/A def background_name(keyword, name, file_colon_line, source_indent)
427N/A @processed_steps << "Background: #{name}"
427N/A print_feature_element_name(keyword, name, file_colon_line, source_indent)
427N/A end
427N/A
427N/A def scenario_name(keyword, name, file_colon_line, source_indent)
427N/A @processed_steps << "Scenario: #{name}"
427N/A print_feature_element_name(keyword, name, file_colon_line, source_indent)
427N/A end
427N/A
427N/A def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
427N/A name_to_report = format_step(keyword, step_match, status, source_indent)
@processed_steps << "Step: #{name_to_report}"
end
def exception(exception, status)
return if @hide_this_step
return if exception.is_a?(Cucumber::Pending)
@processed_steps << format_exception(exception, status, EXCEPTION_INDENT)
@failed = true
end
private
def print_feature_element_name(keyword, name, file_colon_line, source_indent)
names = name.empty? ? [name] : name.split("\n")
line = "#{keyword}: #{names[0]}".indent(SCENARIO_INDENT)
@io.print(line)
@io.print(' [...]') if names[1..-1].present?
@io.flush
end
def print_summary(features)
print_steps(:pending)
print_failure_details
print_stats(features, @options)
print_snippets(@options)
print_passing_wip(@options)
end
def print_failure_details
if @failed_scenario_steps.any?
@io.puts(format_string("(::) steps of failed scenarios (::)", :failed))
@io.puts
@io.flush
end
@failed_scenario_steps.each do |failed_scenario|
failed_scenario.each do |step|
@io.puts step.indent(SCENARIO_INDENT)
end
@io.puts
end
@io.puts
@io.flush
end
def format_exception(e, status, indent)
message = "#{e.message} (#{e.class})".force_encoding("UTF-8")
if ENV['CUCUMBER_TRUNCATE_OUTPUT']
message = linebreaks(message, ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
end
string = "#{message}\n#{e.backtrace.join("\n")}".indent(indent)
format_string(string, status)
end
end