Skip to content

Commit

Permalink
docs: add documentation for the print-unused-definitions option (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-granados authored Feb 14, 2025
1 parent d9a6800 commit 1e3c8f9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions user_guide/command_line_tool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ This is a summary of the usage of Behat in the command line:
Do not print snippets for undefined steps after stats.
--strict
Passes only if all tests are explicitly passing.
--print-unused-definitions
Reports definitions that were never used.
--order=ORDER
Set an order in which to execute the specifications
(this will result in slower feedback).
Expand Down
40 changes: 40 additions & 0 deletions user_guide/command_line_tool/informative_output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,43 @@ You can also search for a specific pattern by running:
#...
That's it, you can now search and browse your whole step dictionary.

Print Unused Definitions
------------------------

If your project is large, you may end up with definitions which are no longer used. If you want to print a list of
these unused definitions you can use the ``--print-unused-definitions`` command line flag. With this flag you will see
output similar to this:

.. code-block:: console
$ behat --print-unused-definitions
...
--- 1 unused definition:
[Then|*] I call a step not used in any feature
`FeatureContext::stepNotUsedInAnyFeature()`
This can also be set for each profile using the PHP configuration:

.. code-block:: php
use Behat\Config\Config;
use Behat\Config\Profile;
return (new Config())
->withProfile(
(new Profile('default'))
->withPrintUnusedDefinitions()
)
;
Or the yaml configuration:

.. code-block:: yaml
default:
definitions:
print_unused_definitions: true

0 comments on commit 1e3c8f9

Please sign in to comment.