Monday, 18 June 2018

Use Behat BDD tests with Drupal 7

Behat is a framework that allows us to write BDD tests, aka given-when-then tests. The language of test specification is quite simple and easy to read and is more business friendly, to know more about BDD you can go here

To use BDD with our drupal 7 site we need to go in the code base, create a folder under sites folder called behat. Installing Behat is done best using composer, so we need to create a composer.json file with the following content

  "require": {
    "drupal/drupal-extension": "~3.0"
  "config": {
    "bin-dir": "bin/"
and save as composer.json 

Instructions are from adding starting steps or steps to make things clear.

Assume composer is installed system wide (you can find better guides to install composer by searching on google).

composer install

This will install all required dependencies (exactly why composer is such a good idea).

Your console will fill up with a lot of information like this: