Class: Cucumber::Formatter::Progress

Inherits:
Object
  • Object
show all
Includes:
Console, Io
Defined in:
lib/cucumber/formatter/progress.rb

Overview

The formatter used for --format progress

Direct Known Subclasses

Usage

Defined Under Namespace

Classes: TestCaseData

Constant Summary

Constants included from ANSIColor

ANSIColor::ALIASES

Constants included from Term::ANSIColor

Term::ANSIColor::ATTRIBUTES, Term::ANSIColor::ATTRIBUTE_NAMES, Term::ANSIColor::COLORED_REGEXP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Io

ensure_dir, ensure_file, ensure_io

Methods included from Console

#collect_snippet_data, #do_print_passing_wip, #do_print_profile_information, #do_print_snippets, #embed, #empty_messages, #exception_message_string, #format_step, #format_string, #linebreaks, #print_element_messages, #print_elements, #print_exception, #print_message, #print_messages, #print_passing_wip, #print_profile_information, #print_snippets, #print_statistics, #print_steps, #print_table_row_messages, #puts

Methods included from ANSIColor

#cukes, define_grey, define_real_grey, #green_cukes, #red_cukes, #yellow_cukes

Methods included from Term::ANSIColor

attributes, coloring=, coloring?, included, #uncolored

Methods included from Duration

#format_duration

Constructor Details

#initialize(config) ⇒ Progress

Returns a new instance of Progress


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cucumber/formatter/progress.rb', line 21

def initialize(config)
  @config, @io = config, ensure_io(config.out_stream)
  @previous_step_keyword = nil
  @snippets_input = []
  @total_duration = 0
  @summary = Cucumber::Core::Report::Summary.new(config.event_bus)
  @matches = {}
  @pending_step_matches = []
  @failed_results = []
  @failed_test_cases = []
  @passed_test_cases = []
  @counts = ConsoleCounts.new(config)
  @issues = ConsoleIssues.new(config)
  config.on_event :step_activated, &method(:on_step_activated)
  config.on_event :test_case_started, &method(:on_test_case_started)
  config.on_event :test_step_finished, &method(:on_test_step_finished)
  config.on_event :test_case_finished, &method(:on_test_case_finished)
  config.on_event :test_run_finished, &method(:on_test_run_finished)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


19
20
21
# File 'lib/cucumber/formatter/progress.rb', line 19

def config
  @config
end

#runtimeObject (readonly)

Returns the value of attribute runtime


18
19
20
# File 'lib/cucumber/formatter/progress.rb', line 18

def runtime
  @runtime
end

#summaryObject (readonly)

Returns the value of attribute summary


19
20
21
# File 'lib/cucumber/formatter/progress.rb', line 19

def summary
  @summary
end

Instance Method Details

#on_step_activated(event) ⇒ Object


41
42
43
# File 'lib/cucumber/formatter/progress.rb', line 41

def on_step_activated(event)
  @matches[event.test_step.source] = event.step_match
end

#on_test_case_finished(event) ⇒ Object


64
65
66
67
68
69
70
# File 'lib/cucumber/formatter/progress.rb', line 64

def on_test_case_finished(event)
  test_case = event.test_case
  result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
  @failed_test_cases << test_case if result.failed?
  @passed_test_cases << test_case if result.passed?
  @total_duration += DurationExtractor.new(result).result_duration
end

#on_test_case_started(_event) ⇒ Object


45
46
47
48
49
50
51
# File 'lib/cucumber/formatter/progress.rb', line 45

def on_test_case_started(_event)
  unless @profile_information_printed
    do_print_profile_information(config.profiles) unless config.skip_profile_information? || config.profiles.nil? || config.profiles.empty?
    @profile_information_printed = true
  end
  @previous_step_keyword = nil
end

#on_test_run_finished(_event) ⇒ Object


72
73
74
75
76
# File 'lib/cucumber/formatter/progress.rb', line 72

def on_test_run_finished(_event)
  @io.puts
  @io.puts
  print_summary
end

#on_test_step_finished(event) ⇒ Object


53
54
55
56
57
58
59
60
61
62
# File 'lib/cucumber/formatter/progress.rb', line 53

def on_test_step_finished(event)
  test_step = event.test_step
  result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
  progress(result.to_sym) if !HookQueryVisitor.new(test_step).hook? || result.failed?

  return if HookQueryVisitor.new(test_step).hook?
  collect_snippet_data(test_step, result)
  @pending_step_matches << @matches[test_step.source] if result.pending?
  @failed_results << result if result.failed?
end