Class: Cucumber::Formatter::Progress
- Inherits:
-
Object
- Object
- Cucumber::Formatter::Progress
- Defined in:
- lib/cucumber/formatter/progress.rb
Overview
The formatter used for --format progress
Direct Known Subclasses
Defined Under Namespace
Classes: TestCaseData
Constant Summary
Constants included from ANSIColor
Constants included from Term::ANSIColor
Term::ANSIColor::ATTRIBUTES, Term::ANSIColor::ATTRIBUTE_NAMES, Term::ANSIColor::COLORED_REGEXP
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Instance Method Summary collapse
-
#initialize(config) ⇒ Progress
constructor
A new instance of Progress.
- #on_step_activated(event) ⇒ Object
- #on_test_case_finished(event) ⇒ Object
- #on_test_case_started(_event) ⇒ Object
- #on_test_run_finished(_event) ⇒ Object
- #on_test_step_finished(event) ⇒ Object
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?, #uncolored
Methods included from 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 |
# File 'lib/cucumber/formatter/progress.rb', line 20 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
#config ⇒ Object (readonly)
Returns the value of attribute config.
18 19 20 |
# File 'lib/cucumber/formatter/progress.rb', line 18 def config @config end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
17 18 19 |
# File 'lib/cucumber/formatter/progress.rb', line 17 def runtime @runtime end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
18 19 20 |
# File 'lib/cucumber/formatter/progress.rb', line 18 def summary @summary end |
Instance Method Details
#on_step_activated(event) ⇒ Object
40 41 42 |
# File 'lib/cucumber/formatter/progress.rb', line 40 def on_step_activated(event) @matches[event.test_step.source] = event.step_match end |
#on_test_case_finished(event) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/cucumber/formatter/progress.rb', line 63 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
44 45 46 47 48 49 50 |
# File 'lib/cucumber/formatter/progress.rb', line 44 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
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
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/cucumber/formatter/progress.rb', line 52 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 |