Download the PHP package jonathanjfshaw/phpunitbehat without Composer
On this page you can find all versions of the php package jonathanjfshaw/phpunitbehat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jonathanjfshaw/phpunitbehat
More information about jonathanjfshaw/phpunitbehat
Files in jonathanjfshaw/phpunitbehat
Package phpunitbehat
Short Description Use Behat from within PHPUnit.
License MIT
Informations about the package phpunitbehat
PHPUnitBehat
PHPUnitBehat provides traits that allow developers to create tests that combine the power & 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
- Behat 3
- PHPUnit 6+
Installation
composer require jonathanjfshaw/phpunitbehat
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.
Create a test that extends the base class, and define a $feature property with corresponding step methods.
Execute your test as usual with phpunit. You should see test output like this:
Running tests
You can specify individual scenarios to run because the scenario title is given as the data provider name. For example to test a scenario with title Undefined
:
More complex possibilities exist; see https://phpunit.de/manual/6.5/en/textui.html#textui.examples.filter-patterns.
Failures and errors
Phpunit will report any instance of AssertionFailedError as a failure and other exceptions as errors. In some circumstances you may wish to display certain exceptions as errors. For example, if you're using Mink for web assertions, you may want to report Mink's ExpectationExpection (which is thrown when web content does not match an expectation) as a failure not an error.
To achieve this, in your test's base class you can catch these errors when scenario results are examined, and rethrow them using the provided AssertionFailedWrappedError:
License
MIT.
All versions of phpunitbehat with dependencies
phpunit/phpunit Version ^9.0 || ^10 || ^11
behat/behat Version ^3.0.0
symfony/dependency-injection Version ^4.0 || ^5.0 || ^6.0 || ^7.0