Support the documentation
This documentation was written by volunteers. Please help support our effort:
The Neos package contains a growing suite of Behat tests which you should take into account while fixing bugs or adding new features. Please note that running these tests require that the Neos demo site package (Neos.Demo) is installed and activated.
Behat is installed in a separate folder and has a custom composer root file. To install Behat run the following composer command in
cd Build/Behat composer install
A special package
Neos.Behat is used to integrate Flow with Behat and is installed if the base distribution was installed with
composer install –dev.
Behat needs two special Flow contexts,
- The context
Development/Behatshould be mounted as a separate virtual host and is used by Behat to do the actual HTTP requests.
- The context
Testing/Behatis used inside the Behat feature context to set up test data and reset the database after each scenario.
These contexts should share the same database to work properly. Make sure to create a new database for the Behat tests since all the data will be removed after each scenario.
Neos: Flow: persistence: backendOptions: dbname: 'neos_testing_behat'
Neos: Flow: persistence: backendOptions: dbname: 'neos_testing_behat' driver: pdo_mysql user: '' password: ''
Example virtual host configuration for Apache:
<VirtualHost *:80> DocumentRoot "FLOW_ROOT/Web" ServerName neos.behat.test SetEnv FLOW_CONTEXT Development/Behat </VirtualHost>
The Behat tests for Neos are shipped inside the Neos.Neos package in the folder
Tests/Behavior. Behat uses a configuration file distributed with Neos,
behat.yml.dist, or a local version,
behat.yml. To run the tests, Behat needs a base URI pointing to the special virtual host running with the
Development/Behat context. To set a custom base URI the default file should be copied and customized:
cd Packages/Application/Neos.Neos/Tests/Behavior cp behat.yml.dist behat.yml # Edit file behat.yml
default: paths: features: Features bootstrap: %behat.paths.features%/Bootstrap extensions: Behat\MinkExtension\Extension: files_path: features/Resources show_cmd: 'open %s' goutte: ~ selenium2: ~ base_url: http://neos.behat.test/
java -jar selenium-server-standalone-2.x.0.jar
If using Saucelabs, you do not need your own Selenium setup.
Behat tests can be run from the Flow root folder with the
bin/behat command by specifying the Behat configuration file:
bin/behat -c Packages/Application/Neos.Neos/Tests/Behavior/behat.yml
In case the executable file
bin/behat is missing, create a symlink by running the following command in
ln -s ../Build/Behat/vendor/behat/behat/bin/behat
FLOW_CONTEXT=Development/Behat ./flow flow:cache:warmup
behat/mink-extensionneed to be at least version 1.3.
Saucelabs (http://saucelabs.com) provides a VM infrastructure you can use to run your selenium tests on.
To run Neos Behat tests with saucelabs you need to do the following steps.
To talk to saucelabs you need to uncomment the following lines in the
behat.yml and add your saucelabs username and access_key:
To make tests with more browsers than the default browser you need to tell saucelabs which browser, version and OS you want to test on. You can add several browsers, each in its own profile. There are a lot of browsers configured already in the
saucelabsBrowsers.yml file. You can include that into your behat configuration:
imports: - saucelabsBrowsers.yml
If you want to run the tests on your local machine you need to open a tunnel to saucelabs. This can be easily done by downloading Sauce Connect at https://docs.saucelabs.com/reference/sauce-connect/ and follow the instructions to setup and start it.
A test with Internet Explorer 10 on Windows8 would look like this then:
bin/behat -c Packages/Application/Neos.Neos/Tests/Behavior/behat.yml --profile windows8-ie-10