Image removed.

As anyone who has used Behat for Drupal knows, configuring it can be difficult.

Using the Drush Behat Params library, you can quickly and easily configure Behat for Drupal testing. This library provides a drush command wrapper for 'bin/behat' with BEHAT_PARAMS already set, eliminating the need to specify the URL, path to code, and drush alias each time you run Behat.

Configuration Confusion

Normally, to set the URL and path to files, you can edit your behat.yml file, but that hardcodes the values so you can only run it in that environment.

You can add a Behat "profile", but then you have to maintain them for each environment and remember to run the correct one. That still doesn't solve the problem of dynamic environments where the path and URL is different for every site.

To run Behat tests with environment-specific settings, you can set the BEHAT_PARAMS environment variable. However this is also challenging because it must be in valid JSON, it can be difficult to determine the right values, and properly scripting your CI system to output those values to the variable is no easy task.

Drush Knows

Drush itself has all of the information Behat needs.

The --root option is the path to Drupal (or default to current directory).

The --uri option is the URL (or default to DRUSH_OPTIONS_URI environment variable).

The drush alias being used is the drush alias to test against.

Old vs New

Now, instead of calling behat like this:

bin/behat --profile=dev

Or this:


You can simply call 

drush behat

No matter where the site is running.

This is especially useful for local development tools like Lando and for CI systems like DevShop. Just replace your bin/behat calls with drush behat!

Use it

To install the plugin, use composer:

composer require drupal-operations/drush-behat-params

Run it with drush:

drush behat

For more information:

For more information on getting Behat setup for your project quickly, stay tuned for a future blog post.


Submitted by admin on