2017 © Pedro Peláez
 

behat-extension around-hook-extension

Around hook support for behat v3

image

chartinger/around-hook-extension

Around hook support for behat v3

  • Saturday, June 7, 2014
  • by chartinger
  • Repository
  • 1 Watchers
  • 2 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

@AroundScenario hook extension

Around hook support for Behat 3, (*1)

This project aims to mimic the Cucumber around feature in Behat 3.x, (*2)

Example

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"

...

Installation

In your composer.json add, (*6)

{
    "require": {
        ...
        "chartinger/around-hook-extension": "*@dev"
    }
}

and update your dependencies, (*7)

Usage

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();
  }

The Versions

07/06 2014

dev-master

9999999-dev

Around hook support for behat v3

  Sources   Download

MIT

The Requires

 

The Development Requires

by Christian Hartinger