From 14b36aae388a96a54b7ac9493d9285fa0e1d90e9 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 17 May 2016 17:29:21 -0700 Subject: [PATCH 1/4] Add timings for each scenario in cucumber --- features/support/formatter.rb | 39 ++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/features/support/formatter.rb b/features/support/formatter.rb index 8ce03bd1..b06d675f 100644 --- a/features/support/formatter.rb +++ b/features/support/formatter.rb @@ -30,6 +30,7 @@ module Jekyll @options = options @exceptions = [] @indent = 0 + @timings = {} end # @@ -42,6 +43,7 @@ module Jekyll def after_features(features) @io.puts + print_worst_offenders print_summary(features) end @@ -54,23 +56,35 @@ module Jekyll # - def tag_name(tag_name); end - - def comment_line(comment_line); end - - def after_feature_element(feature_element); end - - def after_tags(tags); end + def feature_element_timing_key(feature_element) + "\"#{feature_element.name.to_s.sub("Scenario: ", "")}\" (#{feature_element.location})" + end # def before_feature_element(_feature_element) @indent = 2 @scenario_indent = 2 + @timings[feature_element_timing_key(feature_element)] = Time.now end # + def after_feature_element(feature_element) + @timings[feature_element_timing_key(feature_element)] = Time.now - @timings[feature_element_timing_key(feature_element)] + @io.print " (#{@timings[feature_element_timing_key(feature_element)]}s)" + end + + # + + def tag_name(tag_name); end + + def comment_line(comment_line); end + + def after_tags(tags); end + + # + def before_background(_background) @scenario_indent = 2 @in_background = true @@ -178,6 +192,17 @@ module Jekyll # + def print_worst_offenders + @io.puts + @io.puts "Worst offenders:" + @timings.sort_by { |_f, t| -t }.each do |(f, t)| + @io.puts " #{t}s for #{f}" + end + @io.puts + end + + # + def print_summary(features) @io.puts print_stats(features, @options) From 6355a07d4bcfb30cb9c2408e97fa12c1d7bb9f90 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 19 May 2016 08:43:03 -0700 Subject: [PATCH 2/4] Only do top 10 worst offenders in cucumberland --- features/support/formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/support/formatter.rb b/features/support/formatter.rb index b06d675f..a075f18c 100644 --- a/features/support/formatter.rb +++ b/features/support/formatter.rb @@ -195,7 +195,7 @@ module Jekyll def print_worst_offenders @io.puts @io.puts "Worst offenders:" - @timings.sort_by { |_f, t| -t }.each do |(f, t)| + @timings.sort_by { |_f, t| -t }.take_while { |i| i < 10 }.each do |(f, t)| @io.puts " #{t}s for #{f}" end @io.puts From 4b1012537f7b67c4e4c3a690003f5cb1f3cbfc48 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 19 May 2016 09:08:25 -0700 Subject: [PATCH 3/4] Use #take instead of #take_while --- features/support/formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/support/formatter.rb b/features/support/formatter.rb index a075f18c..b216323f 100644 --- a/features/support/formatter.rb +++ b/features/support/formatter.rb @@ -195,7 +195,7 @@ module Jekyll def print_worst_offenders @io.puts @io.puts "Worst offenders:" - @timings.sort_by { |_f, t| -t }.take_while { |i| i < 10 }.each do |(f, t)| + @timings.sort_by { |_f, t| -t }.take(10).each do |(f, t)| @io.puts " #{t}s for #{f}" end @io.puts From 956495f4503d4c1f81d86c5498b9025477f16a54 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 2 Jun 2016 16:47:14 -0700 Subject: [PATCH 4/4] Fix typo. --- features/support/formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/support/formatter.rb b/features/support/formatter.rb index b216323f..22237010 100644 --- a/features/support/formatter.rb +++ b/features/support/formatter.rb @@ -62,7 +62,7 @@ module Jekyll # - def before_feature_element(_feature_element) + def before_feature_element(feature_element) @indent = 2 @scenario_indent = 2 @timings[feature_element_timing_key(feature_element)] = Time.now