- Install package and dependancies
- Remember to set minimum-stability eq dev as there is no stable version of the package.
"require-dev": {
"behat/mink-extension": "^2.1",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
"phpunit/phpunit": "5.2.*",
"behat/symfony2-extension": "^2.1"
},
"minimum-stability": "dev",
"prefer-stable": true
- Create behat.yml on the root of your application
default:
extensions:
Behat\MinkExtension:
base_url: http://localhost:8000
goutte: ~
selenium2: ~
Behat\Symfony2Extension: ~
suites:
default:
contexts:
- FeatureContext
paths: [%paths.base%/features]
- Initialize behat directories by running the following
php vendor/behat/behat/bin/behat --init
-
Access Symfony kernel, through FeatureContext
Edit features/bootstrap/FeatureContext.php as shown below
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Symfony2Extension\Context\KernelDictionary;
use Behat\MinkExtension\Context\MinkContext;
class FeatureContext extends MinkContext
implements Context, SnippetAcceptingContext
{
use KernelDictionary;
public function __construct()
{
}
}
- Create your first feature
- Under features directory create a file called product.feature
Feature: Products
In order to find a dino product
As a web user
I ned to bla bla
Scenario: Searching for dino
Given I am on "/"
When I fill in "searchTerm" with "dino"
And I press "search_submit"
Then I should see "Dino app"
- Run your tests
- In order for this to work you will need to create a sample app and start php built-in server.
php vendor/bin/behat