As time goes on in a project using cucumber you’ll end up with some steps which no longer get called, and you probably want to delete them. Annoyingly, there isn’t a built-in formatter you can use to find out where they are. Sure, the ‘usage’ formatter prints off unused steps, but it prints off all the other steps too! What’s needed is a formatter that will hunt down all steps that are not being used and then print off each step’s name and its location (file location and line number).
What follows is a very basic cucumber formatter that will do just that. To use it, copy the code into a file called ‘
unused.rb‘ in your ‘
features/support‘ folder and then use the formatter when you run cucumber:
cucumber -d -f Cucumber::Formatter::Unused
cucumber -d -f Unused