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

Methods included from Console

#collect_snippet_data, #do_print_passing_wip, #do_print_profile_information, #do_print_snippets, #embed, #exception_message_string, #format_step, #format_string, #linebreaks, #print_element_messages, #print_elements, #print_exception, #print_passing_wip, #print_profile_information, #print_snippets, #print_statistics, #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?, #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
# File 'lib/cucumber/formatter/progress.rb', line 20

def initialize(config)
  @config = config
  @io = ensure_io(config.out_stream)
  @snippets_input = []
  @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)
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.to_s] = event.step_match
end

#on_test_case_finished(event) ⇒ Object


64
65
66
67
68
69
# 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)
  @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
  @current_feature_uri = event.test_case.location.file
end

#on_test_run_finished(_event) ⇒ Object


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

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 !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