Skip to content

Instantly share code, notes, and snippets.

@ahawkins
Created October 5, 2010 01:52
Show Gist options
  • Save ahawkins/610833 to your computer and use it in GitHub Desktop.
Save ahawkins/610833 to your computer and use it in GitHub Desktop.
# run your test suite with this formatter to print out all undefined steps
# Good for finding old and unused steps after a lot of refactoring !
require 'cucumber'
require 'cucumber/formatter/usage'
class UnusedSteps < Cucumber::Formatter::Usage
def print_summary(features)
add_unused_stepdefs
aggregate_info
if @options[:dry_run]
keys = @stepdef_to_match.keys.sort {|a,b| a.regexp_source <=> b.regexp_source}
else
keys = @stepdef_to_match.keys.sort {|a,b| a.mean_duration <=> b.mean_duration}.reverse
end
keys.each do |stepdef_key|
if !@stepdef_to_match[stepdef_key].any?
print_step_definition(stepdef_key)
end
end
@io.puts
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment