PHPackages                             yceruto/behat-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. yceruto/behat-extension

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

yceruto/behat-extension
=======================

Set of Behat extensions

v1.0.2(3mo ago)11.8k1MITPHPPHP &gt;=8.0CI passing

Since Jun 26Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/yceruto/behat-extension)[ Packagist](https://packagist.org/packages/yceruto/behat-extension)[ RSS](/packages/yceruto-behat-extension/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Behat Extension
===============

[](#behat-extension)

Set of [Behat](https://github.com/Behat/Behat) extensions to write better Behat tests.

Exception Extension
-------------------

[](#exception-extension)

This extension provides a way to catch exceptions thrown by your behaviors and check them in your tests.

### Installation

[](#installation)

```
composer require --dev yceruto/behat-extension
```

### Configuration

[](#configuration)

Enable the extension in your `behat.yml`:

```
default:
    extensions:
        Yceruto\BehatExtension\Extension\ExceptionExtension: ~
```

### Usage

[](#usage)

Once the extension is enabled, you can use the `(!)` mark in any scenario title to indicate that all exceptions thrown in this scenario must be caught. By using some predefined Behat steps included in this package, you can then check the exception class and message.

Example:

```
Feature: Manage blog posts
  As a blog owner
  I want to manage my blog posts
  So I can keep my blog up to date

  Scenario: Edit a blog post with invalid date
    Given I get a blog post with id "1"
    And I set a published date "3024-01-01"
    Then an exception should be thrown with message "The published date must be in the past."
```

Note

Note that the `(!)` mark is mandatory to catch exceptions. If you don't use it, the exception will be thrown as usual.

These predefined steps can be found in the `ExceptionAssertionTrait`, which are activated once you add it to your Behat context class. Alternatively, you can create custom Behat steps and use the `ExceptionAssertion` class directly.

This is a sample of the `FeatureContext` class that implements the previous feature:

```
class FeatureContext implements Context
{
    use ExceptionAssertionTrait;

    /**
     * @Given I get a blog post with id :id
     */
    public function iGetABlogPostWithId(int $id): void
    {
        // code that gets the blog post...
    }

    /**
     * @Given I set a published date :date
     */
    public function iSetAPublishedDate(string $date): void
    {
        // code that throws an exception...

        throw new DomainException('The published date must be in the past.');
    }
}
```

License
-------

[](#license)

This software is published under the [MIT License](LICENSE)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance78

Regular maintenance activity

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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 ~285 days

Total

3

Last Release

115d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebf906be9b4bb0c2060846ce9bbfe246df4e32bb5a8741ce1971ee923db2f8ae?d=identicon)[yceruto](/maintainers/yceruto)

---

Top Contributors

[![yceruto](https://avatars.githubusercontent.com/u/2028198?v=4)](https://github.com/yceruto "yceruto (14 commits)")[![nikophil](https://avatars.githubusercontent.com/u/10139766?v=4)](https://github.com/nikophil "nikophil (1 commits)")

---

Tags

bddbehatbehat-extensionphp

### Embed Badge

![Health badge](/badges/yceruto-behat-extension/health.svg)

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

###  Alternatives

[drupal/drupal-extension

Drupal extension for Behat

22215.1M147](/packages/drupal-drupal-extension)[friends-of-behat/symfony-extension

Integrates Behat with Symfony.

48223.4M551](/packages/friends-of-behat-symfony-extension)[friends-of-behat/variadic-extension

Variadic support for behat context arguments

2286.0M446](/packages/friends-of-behat-variadic-extension)[friends-of-behat/mink-extension

Mink extension for Behat

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

Allows to overwrite suites' default settings.

2154.1M387](/packages/friends-of-behat-suite-settings-extension)[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)
