Skip to content

Setting Up Behat Framework

This guide will go through the entire process of getting the behat framework set up on an entirely new project.

We will be using the m1-demo container as a guide and an example.

Things which will be useful to have open:

Step-By-Step Guide

First thing you need to do is create a new directory inside the root of the project, name the new folder testing.

Root: /var/www/vhosts/"project-root"

In this instance the project root will be m1demo so anything following directly after this path is a project root var/www/vhost/


Make sure you create the testing folder inside the project root but outside the public folder

After you have done the above, navigate inside the new folder you have created. When you are there, you will then need to create a new composer.json file.

Inside the file you will want to paste in the below:

     "require": {
         "edmondscommerce/behat-framework": "dev-master",
         "edmondscommerce/behat-faker-context": "dev-master",
         "edmondscommerce/behat-chrome-performance-context": "dev-master",
         "edmondscommerce/behat-error-detection-context": "dev-master",
         "edmondscommerce/behat-screenshot-context": "dev-master",
         "edmondscommerce/behat-error-handling-context": "dev-master",
         "edmondscommerce/behat-html-context": "dev-master",
         "edmondscommerce/behat-javascript-context": "dev-master",
         "edmondscommerce/behat-mouse-context": "dev-master"
     "config": {
         "bin-dir": "bin/"
Then you will need to do the following via the terminal (inside the testing folder)

composer install --prefer-source


To navigate inside the terminal use the following cd /var/www/vhosts/"project-root/testing

  • cd = Change Directory

What you will need to do next is get the features and the behat.yml file from the Edmonds Commerce github, you can find the rest of the instructions below.


cp -R vendor/edmondscommerce/behat-framework/features .

You can then add your features and custom contexts as needed.

Behat Config

cp vendor/edmondscommerce/behat-framework/behat.dist ./behat.yml

You will want to edit this file according to your requirements, but this is a good staritng point.

Behat Folder Structure

This will cover what each folder will contain once the install process is finished.

Features Folder:

This will be where you create any folder you may need to represent a section of a website e.g. checkout, from within this folder you will create feature files that will then be used to contain your scenarios / user stories

You will also see a bootstrap folder, this will contain context files that will be used to define any gherkin steps you may create.


You may actually run into a few problems along the way, below you can find a list of the gotchas and how to correct them.

  • xdebug
  • SSH Key
  • MinkGoutteDriver


This one if fairly straight forward as there is a bash script which will get this all done for you, this will be located in the following place:

Mink Goutte Drive

You might run into this when you actually come to running your tests, if you see this in your terminal output at any point, you will need to do the following:

composer require behat/mink-goutte-driver

This will need to be run from inside the /behat-framework directory

SSH key

If your tests do not seem to run and open a browser window then you might need to do the below:

sudo ssh-copy-id ec@ -p 9516

The above will need to be run from the home of your machine /home/"username"

Once you have done all this go to the following page to learn how to run the tests

Recieving this error on the W3CValidationContext? php_network_getaddresses: getaddrinfo failed: Name or service not known

run : composer show | grep etc-curl in your folder where your composer.json file lives.

If you have no output then you need to run : composer require --dev ext-curl; composer install --prefer-source

Then if not already configured, set the /etc/hosts file with the correct url you are using for your site like {website-ulr}