Using Behat with Drupal
Installing the Drupal Extension for Behat
Installing using Composer
Just follow the instructions at https://drupal.org/project/drupalextension.
You have to create a new composer.json file in your Behat directory. If there is already one from your initial Behat installation just rename it. (You should not add the following code to an existing composer.json file. The Drupal Extension will care for all dependencies itself.) You might also have to rename (or delete) the composer.lock file to be able to run Composer.
Now just run Composer from the command line (here Windows PowerShell):
Composer will update some already installed components and then install the Drupal Extension.
Set up a Drupal project
- Create a Drupal project folder.
- Run behat --init
- Create a behat.yml file (see https://drupal.org/project/drupalextension point 3.)
- Then at least modify the FeatureContext.php file according to point 10.
Check your installation
To check if everything went fine run
to get the definition list of all available steps. There should be some new Drupal specific entries.
As the list might be a bit overwhelming try filtering the list by some Drupal specific term like "node":
behat -d 'node'
The Drupal Extension comes with three different drivers for interacting with a Drupal site (http://www.dspeak.com/drupalextension/drivers.html). The distribution contains some example settings and feature files for these drivers. I'll show how to run these example files in my next blog post on the Drupal Extension for Behat. So stay tuned.