How to find Cucumber steps that are not used

孤街醉人 提交于 2019-12-18 11:45:18

问题


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?


回答1:


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.




回答2:


You could try running your stories under a coverage tool such as simplecov.

By default it will probably exclude test code such as cucumber steps since normally one is interested in how much of the app code is covered rather than how much of the test code, but that should be easy to reverse.



来源:https://stackoverflow.com/questions/8966367/how-to-find-cucumber-steps-that-are-not-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!