Provides Behat BDD support for your Symfony2 project. See Behat official site for more info.
- Support latest Symfony2 release (PR6)
- Fully integrates with Symfony2 project
- Fully tested with Behat itself
- Covers basic functional testing needs
- Beautifull bundle testing possibilities
git submodule add git://github.com/Behat/BehatBundle.git src/Behat/BehatBundle
git submodule add git://github.com/Behat/Gherkin vendor/Gherkin
git submodule add git://github.com/Behat/Behat vendor/Behat
// app/autoload.php
$loader->registerNamespaces(array(
// ...
'Behat\\Gherkin' => __DIR__.'/../vendor/Gherkin/src',
'Behat\\Behat' => __DIR__.'/../vendor/Behat/src',
'Behat\\BehatBundle' => __DIR__.'/../src',
// ...
));
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Behat\BehatBundle\BehatBundle(),
// ...
);
}
# app/config/config.yml
behat.config: ~
BehatBundle have configuration alias:
behat.config
is core configurator of BehatBundle. Specify default formatter parameters and output options here.
For example, by default Behat uses pretty formatter. If you want to always use progress formatter instead of
specifying -f ...
option everytime, add this to your config:
# app/config/config.yml
behat.config:
format:
name: progress
Put your features inside your BundleName/Tests/Features/
directory, steps inside BundleName/Tests/Features/steps
.
hooks.php
, bootstrap.php
and env.php
inside Bundle/Tests/Features/support
.
BehatBundle comes bundled with core steps. Look at them inside Bundle's Behat/BehatBundle/Resources/features
folder. Also, you can view how to use them by looking at Behat/BehatBundle/Tests/Features/*
core BehatBundle tests.
BehatBundle provides some very useful CLI commands for running your features.
This command runs all features inside single bundle:
php app/console behat:test:bundle Application\\HelloBundle
to run HelloBundle application tests. But don't forget to configure routing to include test routes.
This command runs specified feature:
php app/console behat:test:path src/Application/HelloBundle/Tests/Features/SingleFeature.feature
All features inside src/Application/HelloBundle/Tests/Features
folder:
php app/console behat:test:path src/Application/HelloBundle/Tests/Features
Single scenario on line 21 in specified feature:
php app/console behat:test:path src/Application/HelloBundle/Tests/Features/SingleFeature.feature:21
BehatBundle supports all options, that Behat itself supports, including:
--format
or-f
: switch formatter (default ones is progress & pretty)--no-colors
: turn-off colors in formatter--lang ...
: output formatter locale--tags ...
: filter features/scenarios by tag
List of developers who contributed:
- Konstantin Kudryashov (ever.zet@gmail.com)