Class: Cucumber::Formatter::Profile
- Defined in:
- lib/cucumber/formatter/profile.rb
Overview
The formatter used for --format profile
Constant Summary collapse
- NUMBER_OF_STEP_DEFINITONS_TO_SHOW =
10
- NUMBER_OF_STEP_INVOCATIONS_TO_SHOW =
5
Constants included from Console
Constants included from ANSIColor
Instance Attribute Summary
Attributes inherited from Progress
Instance Method Summary collapse
-
#initialize(step_mother, io, options) ⇒ Profile
constructor
A new instance of Profile.
- #print_summary(features) ⇒ Object
- #step(step) ⇒ Object
- #step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
Methods inherited from Progress
#after_features, #after_outline_table, #after_step_result, #before_feature_element, #before_outline_table, #table_cell_value
Methods included from Console
#announce, #format_step, #format_string, #print_counts, #print_elements, #print_exception, #print_passing_wip, #print_snippets, #print_stats, #print_steps, #print_tag_limit_warnings, #record_tag_occurrences
Methods included from ANSIColor
define_grey, define_real_grey, #grey
Methods included from Duration
Constructor Details
#initialize(step_mother, io, options) ⇒ Profile
Returns a new instance of Profile.
10 11 12 13 |
# File 'lib/cucumber/formatter/profile.rb', line 10 def initialize(step_mother, io, ) super @step_definition_durations = Hash.new { |h,step_definition| h[step_definition] = [] } end |
Instance Method Details
#print_summary(features) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cucumber/formatter/profile.rb', line 31 def print_summary(features) super @io.puts "\n\nTop #{NUMBER_OF_STEP_DEFINITONS_TO_SHOW} average slowest steps with #{NUMBER_OF_STEP_INVOCATIONS_TO_SHOW} slowest matches:\n" mean_durations = map_to_mean_durations(@step_definition_durations) mean_durations = mean_durations.sort_by do |duration_description_location, step_definition, mean_duration| mean_duration end.reverse mean_durations[0...NUMBER_OF_STEP_DEFINITONS_TO_SHOW].each do |duration_description_location, step_definition, mean_duration| print_step_definition(step_definition, mean_duration) duration_description_location = duration_description_location.sort_by do |duration, description, location| duration end.reverse print_step_definitions(duration_description_location, step_definition) end end |
#step(step) ⇒ Object
15 16 17 18 19 |
# File 'lib/cucumber/formatter/profile.rb', line 15 def step(step) @step_duration = Time.now @step = step super end |
#step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/cucumber/formatter/profile.rb', line 21 def step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) duration = Time.now - @step_duration super if step_match.step_definition description = format_step(keyword, step_match, status, nil) @step_definition_durations[step_match.step_definition] << [duration, description, @step.file_colon_line] end end |