Find Unused Cucumber Step Definitions
One of the challenges of using cucumber is properly managing your step definitions. Left unchecked, you will eventually have many unused steps. It's extremely cumbersome to prune these manually. Luckily, you can use cucumber's -f / --format
flag to get feedback on unused step_definitions and their locations:
bundle exec cucumber --dry-run --format=stepdefs
If your step definition is unused, it will be annotated with a line under that says NOT MATCHED BY ANY STEPS
. See the example -
/^I submit the proposal request form$/ # features/step_definitions/contact_steps.rb:39
NOT MATCHED BY ANY STEPS
Tweet