7

Are there any tools or extensions to detect unused steps in Behat? We have a huge number of tests code, it is time consuming to check each single step is in-use or not. So I'm thinking if any tools can do that. Any suggestions?

2

3 Answers 3

1

One approach is to copy files into a cucumber based project and run

cucumber --dry-run -f stepdefs

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

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

0

This is just an idea, but it should work.

You need to check all the regular expressions from steps in a result report.

For example:

1) create a complete report running all active scenarios with --dry-run
2) save all the regular expressions using running behat with -dl

Now you have 2 files all scenarios and all regular expressions, now all you should need to do is to do a foreach in the regular expressions and look it in the report file and maybe count the matches as well.

The search could be done in php or with any other tool that can handle regular expressions.

0

You can make use of code coverage tools for PHP.

xdebug has Code Coverage Analysis.

Check this chapter of the PHPUnit Manual

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.