ruby-on-railscucumberbdd

How to find Cucumber steps that are not used


I've been working with Cucumber for about a year and have been continually refactoring the features and step definitions along the way. I have tons of steps defined across many files and I can't help but feel like many of them are no longer needed. Is there a way to find which cucumber step definitions are no longer being used?


Solution

  • The stepdefs formatter can do this, e.g.:

    cucumber --dry-run -f stepdefs
    

    It will print 'NOT MATCHED BY ANY STEPS' for any non-matches.

    If you have any steps that are only used by other steps, then omit --dry-run to get accurate results. With --dry-run, the steps are not executed and cucumber will not find out that the referred step is actually used.