Behat Bundle brings the Behavior Driven Development (as known as BDD) into the eZ Publish.
Using latest Behat 3 and defining sentences with Turnip language, making scenarios it is easier than ever!
Important - Behat Bundle is still improving (a work in progress) so it's possible that deep changes may occur
BehatBundle should be installed by default (unless --no-dev
was used in composer). To verity this, jump to How to run tests
If it is not installed, you can:
- Get Behat bundle:
- Through composer, run on console:
$ php composer.phar require "ezsystems/behatbundle": "*"
- Through
git clone
:$ git clone https://github.com/ezsystems/BehatBundle vendor/ezsystems/behatbundle/EzSystems/BehatBundle
- Download from GitHub:
- download BehatBundle and unzip it in
<ezpublish-root>/vendor/ezsystems/behatbundle/EzSystems/BehatBundle
- download BehatBundle and unzip it in
- Add Behat Bundle to load list (under dev)
- Edit
<ezpublish-root>/ezpublish/EzPublishKernel.php
- Add
new EzSystems\BehatBundle\EzSystemsBehatBundle(),
to$bundles
inEzPublishKernel::registerBundles()
Notice:
- behaviour tests should be done in production environment, since the scenarios should reflect end user interaction with the system.
When javascript interacion isn't needed to test content/browser behavior, Goutte is used (through MinkGoutteDriver), which is much faster than using a real browser.
However, when a real browser is needed, (because a given scenario requires the use of javascript, for example), Goutte is not sufficient. In this case, Sahi or Selenium2 must be used (again through each driver MinkSahiDriver and MinkSelenium2Driver).
So either one of these must be installed and running (Sahi is the one enabled by default), the configured browser is also required Firefox is the default). These settings can be easily changed on behat.yml
at:
default:
extensions:
Behat\MinkExtension:
javascript_session: sahi
browser_name: firefox
Simply run:
$ php bin/behat --profile <profile> [--suite <suite>]
Defined profiles (and suites):
setupWizard
demoContent
- make a Demo with content installationdemoContentNonUniqueDB
- in cases where more than 1 database system is installed on machinedemoClean
- make a clean installation of DemodemoCleanNonUniqueDB
- same asdemoContentNonUniqueDB
demo
:content
- asserts the demo content is correct
rest
:fullJson
- runs all tests with JSON body type and Buzz driverfullXml
- same hasfullJson
but with XML body typeguzzle
- runs all tests with JSON body type but using Guzzle driver
Notice:
setupWizard
profile can only be run when installation is not done and it can't be repeatedsetupWizard
has the database definitions set on the feature files, so you need to have the dabase system, database and user created (take a look at demo.feature)
- SetupWizard profile needs PROD environment defined (otherwise it will find duplicate html elements)