2017 © Pedro Peláez
 

library behat-command-runner-extension

Extension to run commands at hooks in test lifecycle

image

adamquaile/behat-command-runner-extension

Extension to run commands at hooks in test lifecycle

  • Monday, October 20, 2014
  • by adamquaile
  • Repository
  • 3 Watchers
  • 11 Stars
  • 22,727 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 15 % Grown

The README.md

Behat Command Runner extension

This is a proof-of-concept - use with caution!, (*1)

Extension to run commands at hooks in test lifecycle, useful for cache clearing, database setup, teardown, etc..., (*2)

Installation

Require package adamquaile/behat-command-runner-extension via composer:, (*3)

composer require --dev "adamquaile/behat-command-runner-extension *@dev"

Add configuration to your behat.yml. This example shows the full configuration options., (*4)

default:
    extensions:
        AdamQuaile\Behat\CommandRunnerExtension:
              beforeSuite:
                  - echo "beforeSuite"
                  - { command: 'ping example.com', background: true }
              afterSuite:
                  - echo "afterSuite"
              beforeFeature:
                  - echo "beforeFeature"
                  - { command: 'ping example.com', background: true }
              afterFeature:
                  - echo "afterFeature"
              beforeScenario:
                  - echo "beforeScenario"
                  - { command: 'ping example.com', background: true }
              afterScenario:
                  - echo "afterScenario"

A symfony2 example

This example runs phantomjs for our javascript behat tests, and also creates and recreates a test database for each feature., (*5)

For speed, the database is copied back into place after the first run during setup rather than using doctrine each time., (*6)

For more isolation, you could do this copying on beforeScenario rather than beforeFeature., (*7)

default:
    extensions:
        AdamQuaile\Behat\CommandRunnerExtension:
              beforeSuite:
                  - rm app/var/test.db 
                  - php app/console --env=test doctrine:database:drop --force
                  - php app/console --env=test doctrine:database:create --force
                  - php app/console --env=test doctrine:schema:update --force
                  - cp app/var/test.db app/var/test.initial.db
                  - { command: 'phantomjs-1.9.7-linux-x86_64/bin/phantomjs" --webdriver=4444  >"phantomjs.log"', background: true }
              beforeFeature:
                  - cp app/var/test.initial.db app/var/test.db

The Versions

20/10 2014

dev-master

9999999-dev

Extension to run commands at hooks in test lifecycle

  Sources   Download

The Requires

 

02/10 2014

v0.1.1

0.1.1.0

Extension to run commands at hooks in test lifecycle

  Sources   Download

The Requires

 

02/10 2014

dev-feature/behat-tests

dev-feature/behat-tests

Extension to run commands at hooks in test lifecycle

  Sources   Download

The Requires

 

02/10 2014

v0.1.0

0.1.0.0

Extension to run commands at hooks in test lifecycle

  Sources   Download

The Requires