Process below is done manually but if you use bin/behat --init --suite=backend it would create folder structure right under root folder.


Composer.json


{
"require-dev": {
"behat/behat" : "3.0.15",
"behat/symfony2-extension" : "2.0.0",
"behat/mink": "1.6.1",
"behat/mink-extension": "2.0.1",
"behat/mink-browserkit-driver": "1.2.0",
"behat/mink-goutte-driver": "1.1.0",
"behat/mink-selenium2-driver": "1.2.0"
}
}

Behat.yml


default:
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: http://football.local/app_test.php
browser_name: firefox
sessions:
goutte: # fast, CLI, browser, no javascript support
goutte: ~
selenium2: # fast, CLI, opens up a browser
selenium2: ~
symfony2: # very fast, CLI, no browser
symfony2: ~
suites:
backend:
type: symfony_bundle
bundle: ApplicationBackendBundle
mink_session: symfony2
contexts:
- Application\BackendBundle\Features\Context\FeatureContext:
param1: hello
param2: world
frontend:
type: symfony_bundle
bundle: ApplicationFrontendBundle
mink_session: symfony2
contexts:
- Application\FrontendBundle\Features\Context\FeatureContext:
param1: hello
param2: world

FeatureContext.php


Same copy goes into "FrontendBundle" as well.


namespace Application\BackendBundle\Features\Context;

use Behat\MinkExtension\Context\MinkContext;
use Behat\Symfony2Extension\Context\KernelAwareContext;
use Symfony\Component\HttpKernel\KernelInterface;

class FeatureContext extends MinkContext implements KernelAwareContext
{
private $kernel;
private $param1;
private $param2;

public function __construct($param1, $param2)
{
$this->param1 = $param1;
$this->param2 = $param2;
}

public function setKernel(KernelInterface $kernelInterface)
{
$this->kernel = $kernelInterface;
}

/**
* @Given /^I can access service container$/
*/
public function iCanAccessServiceContainer()
{
$container = $this->kernel->getContainer();
echo $container->getParameter('secret');
}
}

Tests


# Backend
Feature: Dummy feature

Scenario: Home url
Given I am on "/backend"
Then I should see "Welcome to Application backend!"
And I can access service container

# Frontend
Feature: Dummy feature

Scenario: Home url
Given I am on "/"
Then I should see "Welcome to Application frontend!"
And I can access service container

Output


Inanzzz-MBP:football inanzzz$ bin/behat --suite=backend
Feature: Dummy feature

Scenario: Home url
Given I am on "/backend"
Then I should see "Welcome to Application backend!"
And I can access service container
│ ThisTokenIsNotSoSecretChangeIt

1 scenario (1 passed)
3 steps (3 passed)
0m0.98s (28.17Mb)
Inanzzz-MBP:football inanzzz$ bin/behat --suite=frontend
Feature: Dummy feature

Scenario: Home url
Given I am on "/"
Then I should see "Welcome to Application frontend!"
And I can access service container
│ ThisTokenIsNotSoSecretChangeIt

1 scenario (1 passed)
3 steps (3 passed)
0m0.17s (27.34Mb)