PHPackages                             jonathanjfshaw/phpunitbehat - 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. jonathanjfshaw/phpunitbehat

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

jonathanjfshaw/phpunitbehat
===========================

Use Behat from within PHPUnit.

0.21(1y ago)2143.8k↓44.6%10[1 PRs](https://github.com/jonathanjfshaw/phpunitbehat/pulls)1MITPHPPHP ^8.2 || ^8.3CI passing

Since Feb 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jonathanjfshaw/phpunitbehat)[ Packagist](https://packagist.org/packages/jonathanjfshaw/phpunitbehat)[ RSS](/packages/jonathanjfshaw-phpunitbehat/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (12)Used By (1)

PHPUnitBehat
============

[](#phpunitbehat)

PHPUnitBehat provides traits that allow developers to create tests that combine the power &amp; flexibility of PHPUnit with the readability of Behat.

By including these traits in your PHPUnit test classes you can:

- use PHPUnit as your test runner as usual
- parse (Behat) Gherkin features in your PHPUnit tests
- write features as text in your PHPUnit test classes
- execute features in your PHPUnit tests
- declare methods in your PHPUnit test that are automatically matched to feature steps
- have the scenario results output as PHPUnit test results

Requirements
------------

[](#requirements)

- Behat 3
- PHPUnit 6+

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

[](#installation)

`composer require jonathanjfshaw/phpunitbehat`

Usage
-----

[](#usage)

A selection of test traits are provided that help you to make use of Behat within PHPUnit with varying degress of control.

The simplest way is to use `PHPUnitBehat\TestTraits\BehatTestTrait`in your test's base class.

```
namespace MyProject\Tests;

use PHPUnit\Framework\TestCase;
use PHPUnitBehat\TestTraits\BehatTestTrait;

class MyTestBase extends TestCase {
  use BehatTestTrait;
}
```

Create a test that extends the base class, and define a $feature property with corresponding step methods.

```
namespace MyProject\Tests;

class MyTest extends MyTestBase {

  protected $feature =
