Behatch contexts provide most common behat tests.
This extension requires:
- Behat 2.4+
- Mink 1.4+
- Mink extension
Download the .phar archives:
- behat.phar - Behat itself
- mink.phar - Mink framework
- behatch_contexts.phar - Behatch contexts
And activate it in your in your behat.yml:
# behat.yml
default:
# ...
extensions:
behatch_contexts.phar: ~The easiest way to keep your suite updated is to use Composer.
You can add behatch contexts as dependancies for your project or rapidly bootstrap a behatch projects.
- Define dependencies in your
composer.json:
{
"require": {
...
"sanpi/behatch-contexts": "*"
}
}- Install/update your vendors:
$ curl http://getcomposer.org/installer | php
$ php composer.phar install- Activate extension by specifying its class in your
behat.yml:
# behat.yml
default:
# ...
extensions:
Sanpi\Behatch\Extension: ~- Download the behatch skeleton with composer:
$ curl http://getcomposer.org/installer | php
$ php composer.phar create-project sanpi/behatch-skeletonNote
Browser, json, table and rest step need a mink configuration, see Mink extension for more informations.
In your main context, using behatch contexts:
<?php
use Behat\Behat\Context\BehatContext;
use Sanpi\Behatch\Context\BehatchContext;
class FeatureContext extends BehatContext
{
public function __construct(array $parameters)
{
$this->useContext('behatch', new BehatchContext($parameters));
}
}After this, you wouldn't have new available step. You should enable,
in behat.yml, the desired steps group:
Sanpi\Behatch\Extension:
contexts:
browser: ~
debug: ~
system: ~
json: ~
table: ~
rest: ~
xml: ~browser- more browser related steps (like mink)debug- helper steps for debugingscreenshot_dir- the directory where store screenshots
system- shell related stepsroot- the root directory of the filesystem
json- JSON related stepsevaluation_mode- javascript "foo.bar" or php "foo->bar"
table- play with HTML the tablesrest- send GET, POST, … requests and test the HTTP headersxml- XML related steps