How to install a working behat (bin only) on a Symfony project
@homepage
Feature: Homepage working as expected (file is in features/homepage.feature)
Scenario: Homepage login
When I go to "/"
Then I should see "Bienvenue"
<?php
//this file is in "features/Context/FeatureContext.php"
namespace Context;
use Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Symfony\Component\HttpKernel\KernelInterface;
class FeatureContext extends MinkContext implements KernelAwareInterface
{
private $kernel;
public function __construct()
{
//add sub contexts here
}
/**
* Sets Kernel instance.
*
* @param KernelInterface $kernel HttpKernel instance
*/
public function setKernel(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
/**
* Returns Container instance.
*
* @return ContainerInterface
*/
private function getContainer()
{
return $this->kernel->getContainer();
}
}
{
"autoload": {
"psr-0": {
"": "src/",
"Context": "features/" /*don't forget this*/
}
},
"require": {
...
"behat/behat": "2.4.*@stable",
"behat/mink-extension": "*",
"behat/symfony2-extension": "*",
"behat/mink-browserkit-driver": "*"
},
}
default:
formatter:
name: pretty
paths:
features: features
context:
class: Context\FeatureContext
extensions:
Behat\MinkExtension\Extension:
default_session: symfony2
show_cmd: 'open -a Firefox.app %s'
base_url: http://myproject.dev
Behat\Symfony2Extension\Extension: ~