PHPackages                             nicwortel/behat-unused-step-definitions-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. nicwortel/behat-unused-step-definitions-extension

ActiveLibrary[Testing &amp; Quality](/categories/testing)

nicwortel/behat-unused-step-definitions-extension
=================================================

A Behat extension that detects unused step definitions

v1.2.0(1y ago)1055.3k—1.7%2MITPHPPHP ^8.1

Since Feb 18Pushed 1y agoCompare

[ Source](https://github.com/nicwortel/behat-unused-step-definitions-extension)[ Packagist](https://packagist.org/packages/nicwortel/behat-unused-step-definitions-extension)[ RSS](/packages/nicwortel-behat-unused-step-definitions-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (8)Versions (7)Used By (0)

Behat Unused Step Definitions Extension
=======================================

[](#behat-unused-step-definitions-extension)

Do you have a large Behat test suite? Would you like to check your feature contexts for unused step definitions? This Behat extension detects and reports step definitions that are not being used in any of your `*.feature` files.

[![License](https://camo.githubusercontent.com/05eb932168233bb25574945c1237d994b9ec670e199fc9f2800a9688b1afd577/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e6963776f7274656c2f62656861742d756e757365642d737465702d646566696e6974696f6e732d657874656e73696f6e)](https://github.com/nicwortel/behat-unused-step-definitions-extension/blob/master/LICENSE.txt)[![Required PHP version](https://camo.githubusercontent.com/7aa5832071b949c18e4313d8148a3d0f0e44ca3e234158939ab744ebd5cad0ea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6e6963776f7274656c2f62656861742d756e757365642d737465702d646566696e6974696f6e732d657874656e73696f6e)](https://github.com/nicwortel/behat-unused-step-definitions-extension/blob/master/composer.json)[![Current version](https://camo.githubusercontent.com/2535ea34324f4bc22631e45a889f122fdab8011248c8e11fe4bb6bd73e73ab27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6963776f7274656c2f62656861742d756e757365642d737465702d646566696e6974696f6e732d657874656e73696f6e)](https://packagist.org/packages/nicwortel/behat-unused-step-definitions-extension)

[![Screenshot](docs/screenshot.png)](docs/screenshot.png)

Installation
------------

[](#installation)

```
composer require --dev nicwortel/behat-unused-step-definitions-extension
```

Activate the extension in your `behat.yml`:

```
default:
  extensions:
    NicWortel\BehatUnusedStepDefinitionsExtension\Extension: ~
```

Usage
-----

[](#usage)

After following the installation steps as documented above, simply run Behat. Instead of actually executing the tests, a dry run will be enough to collect information about unused step definitions:

```
vendor/bin/behat --dry-run
```

Note that if you have multiple suites, the unused step definitions will be listed per suite after the suite has finished.

### Filtering the results

[](#filtering-the-results)

#### Include / exclude

[](#include--exclude)

There are projects where it's important to avoid some step definitions to be detected. For instance, when a project wants to avoid scanning unused step definitions from the third-party packages/libraries and show only results from the custom code. The extension allows to configure a list of *regular expressions* to include or exclude step definitions in the `behat.yml`configuration file. Expressions are compared against the FQCN + method name (`My\Namespace\ClassName::methodName`):

```
default:
  extensions:
    NicWortel\BehatUnusedStepDefinitionsExtension\Extension:
      filters:
        include:
          - '/MyProject\\Behat\\Contexts/'
          - '/OtherProject\\Behat\\(Foo|Bar)Context/'
        exclude:
          - '/MyProject\\Behat\\Contexts\\FeatureContext/'
          - '/::excludedMethod/'
          - '/OtherProject\\Behat\\FooContext::.+Method/'
```

#### Ignore pattern aliases

[](#ignore-pattern-aliases)

Example:

```
/**
 * @Then I take a screenshot
 * @Then I take a screenshot :name
 */
public function takeScreenshot(?string $name = NULL): void {
  // Step implementation.
}
```

If `I take a screenshot` is used but `I take a screenshot :name` is not, enabling `ignorePatternAliases: true` will prevent the latter from being reported as unused.

```
default:
  extensions:
    NicWortel\BehatUnusedStepDefinitionsExtension\Extension:
      ignorePatternAliases: true
```

Extending
---------

[](#extending)

By default, the extension uses the `unused_step_definitions_printer` printer, shipped in the package. The printer displays the list of unused step definitions in the console. Third-party Behat extension might provide different printers (e.g. one may build a text file with the list of unused step definitions). A custom printer should be defined as a container service and should implement the `\NicWortel\BehatUnusedStepDefinitionsExtension\UnusedStepDefinitionsPrinter`interface. Using a custom printer is possible by providing its service ID in the `behat.yml` configuration file:

```
default:
  extensions:
    NicWortel\BehatUnusedStepDefinitionsExtension\Extension:
      printer: my_custom_printer
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 67.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~320 days

Recently: every ~368 days

Total

6

Last Release

677d ago

Major Versions

v0.2.0 → v1.0.02021-01-16

PHP version history (3 changes)v0.1.0PHP ^7.2

v1.0.0PHP ^7.4 || ^8.0

v1.1.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/10e323af547b024081ad8624913ed5fe6a5f99ab407fe8d037189751628d57aa?d=identicon)[nicwortel](/maintainers/nicwortel)

---

Top Contributors

[![nicwortel](https://avatars.githubusercontent.com/u/1055691?v=4)](https://github.com/nicwortel "nicwortel (42 commits)")[![claudiu-cristea](https://avatars.githubusercontent.com/u/473868?v=4)](https://github.com/claudiu-cristea "claudiu-cristea (12 commits)")[![vever001](https://avatars.githubusercontent.com/u/1317919?v=4)](https://github.com/vever001 "vever001 (8 commits)")

---

Tags

behatbehat-extension

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nicwortel-behat-unused-step-definitions-extension/health.svg)

```
[![Health](https://phpackages.com/badges/nicwortel-behat-unused-step-definitions-extension/health.svg)](https://phpackages.com/packages/nicwortel-behat-unused-step-definitions-extension)
```

###  Alternatives

[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[friends-of-behat/mink-extension

Mink extension for Behat

14034.2M467](/packages/friends-of-behat-mink-extension)[friends-of-behat/variadic-extension

Variadic support for behat context arguments

2286.0M446](/packages/friends-of-behat-variadic-extension)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[bex/behat-extension-driver-locator

Driver locator tool for behat extensions

385.2M4](/packages/bex-behat-extension-driver-locator)[wp-cli/wp-cli-tests

WP-CLI testing framework

422.7M87](/packages/wp-cli-wp-cli-tests)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
