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?
An annotation followed by the pattern is used to link the Step Definition to all the matching Steps, and the code is what Cucumber will execute when it sees a Gherkin Step. Cucumber finds the Step Definition file with the help of the Glue code in Cucumber Options.
Dry Run is nothing but checking the complete implementation of all the mentioned steps present in the Feature file. Before the execution starts . Dry Run is Checking the implementionation not about the execution of scripts.
The scenario name can be retrieved using the getName() function.
If Cucumber is telling you that your steps are undefined, when you have defined step definitions, this means that Cucumber cannot find your step definitions. You'll need to make sure to specify the path to your step definitions (glue path) correctly.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With