Add timings for each scenario in cucumber

This commit is contained in:
Parker Moore 2016-05-17 17:29:21 -07:00
parent b5cff52f02
commit 14b36aae38
No known key found for this signature in database
GPG Key ID: 193CDEBA72063C58
1 changed files with 32 additions and 7 deletions

View File

@ -30,6 +30,7 @@ module Jekyll
@options = options @options = options
@exceptions = [] @exceptions = []
@indent = 0 @indent = 0
@timings = {}
end end
# #
@ -42,6 +43,7 @@ module Jekyll
def after_features(features) def after_features(features)
@io.puts @io.puts
print_worst_offenders
print_summary(features) print_summary(features)
end end
@ -54,23 +56,35 @@ module Jekyll
# #
def tag_name(tag_name); end def feature_element_timing_key(feature_element)
"\"#{feature_element.name.to_s.sub("Scenario: ", "")}\" (#{feature_element.location})"
def comment_line(comment_line); end end
def after_feature_element(feature_element); end
def after_tags(tags); end
# #
def before_feature_element(_feature_element) def before_feature_element(_feature_element)
@indent = 2 @indent = 2
@scenario_indent = 2 @scenario_indent = 2
@timings[feature_element_timing_key(feature_element)] = Time.now
end 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) def before_background(_background)
@scenario_indent = 2 @scenario_indent = 2
@in_background = true @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) def print_summary(features)
@io.puts @io.puts
print_stats(features, @options) print_stats(features, @options)