Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add documentation for the print-unused-definitions option #187

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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