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 Method Summary collapse

Methods included from Io

ensure_dir, ensure_file, ensure_io, included, io?, url?

Methods included from Console

#attach, #collect_snippet_data, #collect_undefined_parameter_type_names, #do_print_passing_wip, #do_print_profile_information, #do_print_snippets, #do_print_undefined_parameter_type_snippet, #exception_message_string, #format_step, #format_string, #indent, #linebreaks, #print_element_messages, #print_elements, #print_exception, #print_passing_wip, #print_profile_information, #print_snippets, #print_statistics

Methods included from ANSIColor

apply_custom_colors, #cukes, #green_cukes, #red_cukes, #yellow_cukes

Methods included from Term::ANSIColor

#attributes, included, #uncolored

Methods included from Duration

#format_duration

Constructor Details

#initialize(config) ⇒ Progress

Returns a new instance of Progress.



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

def initialize(config)
  @config = config
  @io = ensure_io(config.out_stream, config.error_stream)
  @snippets_input = []
  @undefined_parameter_types = []
  @total_duration = 0
  @matches = {}
  @pending_step_matches = []
  @failed_results = []
  @passed_test_cases = []
  @current_feature_uri = ''
  @gherkin_documents = {}
  @ast_lookup = AstLookup.new(config)
  @counts = ConsoleCounts.new(config)
  @issues = ConsoleIssues.new(config, @ast_lookup)
  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)
  config.on_event :undefined_parameter_type, &method(:collect_undefined_parameter_type_names)
end

Instance Method Details

#on_step_activated(event) ⇒ Object



43
44
45
# File 'lib/cucumber/formatter/progress.rb', line 43

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

#on_test_case_finished(event) ⇒ Object



67
68
69
70
71
72
# File 'lib/cucumber/formatter/progress.rb', line 67

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

#on_test_case_started(event) ⇒ Object



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

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
  @current_feature_uri = event.test_case.location.file
end

#on_test_run_finished(_event) ⇒ Object



74
75
76
77
78
# File 'lib/cucumber/formatter/progress.rb', line 74

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

#on_test_step_finished(event) ⇒ Object



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

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 !test_step.hook? || result.failed?

  return if test_step.hook?

  collect_snippet_data(test_step, @ast_lookup) if result.undefined?
  @pending_step_matches << @matches[test_step.to_s] if result.pending?
  @failed_results << result if result.failed?
end