dev-master
9999999-devAround hook support for behat v3
MIT
The Requires
- php >=5.3.2
- behat/behat ~3.0.0@dev
The Development Requires
by Christian Hartinger
Wallogit.com
2017 © Pedro Peláez
Around hook support for behat v3
Around hook support for Behat 3, (*1)
This project aims to mimic the Cucumber around feature in Behat 3.x, (*2)
Given you want to run the same Scenario with multiple screen resolutions it could look like this:, (*3)
...
/**
* @AroundScenario
*/
public function runWithMultipleWindowSizes(AroundScenarioScope $scope)
{
$this->width = 1920;
$scope->callBlock(" [1920]");
$this->width = 800;
$scope->callBlock(" [800]");
}
/**
* @BeforeScenario
*/
public function resizeWindow()
{
$this->getSession()->resizeWindow($this->width, $this->height);
}
...
Where in the optional parameter of callBlock() you can define a suffix to the scenario title, (*4)
Example output of Behat could be:, (*5)
...
Scenario: Simpler Test [1920]
Given I am on "http://somehomepage"
When I do something
Then i should see "Hello World"
Scenario: Simpler Test [800]
Given I am on "http://somehomepage"
When I do something
Then i should see "Hello World"
...
In your composer.json add, (*6)
{
"require": {
...
"chartinger/around-hook-extension": "*@dev"
}
}
and update your dependencies, (*7)
To activate this extension add this to your behat.yml, (*8)
default:
extensions:
chartinger\Behat\AroundHookExtension\AroundHookExtension: ~
You can now use the @AroundScenario annotation in your Behat Context, (*9)
use chartinger\Behat\AroundHookExtension\AroundScenarioScope;
...
/**
* @AroundScenario
*/
public function aroundScenario(AroundScenarioScope $scope)
{
$scope->callBlock();
}
Around hook support for behat v3
MIT