Skip to content

Bundle for common reusable sentance implementations & other common needs for Behat testing in eZ bundles/projects.

License

Notifications You must be signed in to change notification settings

micszo/BehatBundle

 
 

Repository files navigation

eZ Publish Behat Bundle

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

How to install

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:

  1. 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
  1. Add Behat Bundle to load list (under dev)
  • Edit <ezpublish-root>/ezpublish/EzPublishKernel.php
  • Add new EzSystems\BehatBundle\EzSystemsBehatBundle(), to $bundles in EzPublishKernel::registerBundles()

Notice:

  • behaviour tests should be done in production environment, since the scenarios should reflect end user interaction with the system.

Browser testing

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

How to run tests

Simply run:

  • $ php bin/behat --profile <profile> [--suite <suite>]

Defined profiles (and suites):

  • setupWizard
    • demoContent - make a Demo with content installation
      • demoContentNonUniqueDB - in cases where more than 1 database system is installed on machine
      • demoClean - make a clean installation of Demo
        • demoCleanNonUniqueDB - same asdemoContentNonUniqueDB
  • demo:
    • content - asserts the demo content is correct
  • rest:
    • fullJson - runs all tests with JSON body type and Buzz driver
    • fullXml - same has fullJson but with XML body type
      • guzzle - 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 repeated
  • setupWizard 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)

Known issues

  • SetupWizard profile needs PROD environment defined (otherwise it will find duplicate html elements)

About

Bundle for common reusable sentance implementations & other common needs for Behat testing in eZ bundles/projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 96.1%
  • Gherkin 3.9%