Which behat module to use?

Events happening in the community are now at Drupal community events on www.drupal.org.
tunic's picture

There are several modules in Drupal.org about Behat:

  • behat: Last commit 25 weeks ago. It allows you to write feature tests for a Drupal site using SimpleTest API functions and assertions in step definitions.
  • behat_testing: Last commit 15 weeks ago. Integrates behat with drush and adds own step definitions for Drupal.
  • drupalextension: Last commit 1 week ago. Provides a DrupalExtension with Drupal step definitions.
  • doobie: Last commit 1 week ago. It seems to be used to test Drupal,org site with behat.

What module do you use for testing Durpal sites? Are those modules intended for the same use? Or are they covering different use cases?

Comments

behat_testing and drupalextension

tunic's picture

I've used behat_testing and drupalextension.

behat_testing provides step definitions and drush integration. Also, behat_testing integrates with the SimpleTest way of cloing DB, so you can launch test on a test DB easily (but you can't use Selenium Mink driver, see this issue:http://drupal.org/node/1850946). Compatible with D7.

Also, behat_testing requires to install behat system wide, so you only need one behat installation to use behat on several Drupal sites.

DrupalExtension is not really a Drupal module, but a behat extension. It provides a behat extension with step definitions for Drupal. I've not checked it in deep but it seems it has more step definitions than behat_testing. it requieres to install behat in every Drupal site you want to test (but I guess it may be possible to use a system wide behat installation). Also, DrupalExtension is compatible at least with D6 and D7.

In general I prefer how behat_testing uses behat because files are located bellow sites. DrupalExtension requeriment of installing behat ends you with a bunch of directories and files in the root dir (vendor, bin, features and behat.yml). But DrupalExtension seems to be more powerful and maintained. Also, Portland sessions talked about DrupalExtension and no other module, if I remember well.

DrupalExtension works realy

rosk0's picture

DrupalExtension works realy well.

Does it work with a behat system wide installation?

tunic's picture

I don't like to install behat on every site to use Drupal Extension. I guess you install behat system wide (including the Drupal Extension), and set up behat to keep behat files under sites, so you don't pollute Drupal filesystem. Do you know if it's possible?

I like Drupal Extension, it seems to be well maintained, but I'd like to avoid mentioned problems.

Done

tunic's picture

Well, I've tested it and it seems to work:

  • Install behat system wide (for example, at /opt/behat and use a symlink from /usr/local/bin or another directory in your path).

  • Put your behat.yml in sites/default/

  • Put your features dir inside sites/all. This includes a bootstrap directory that holds your FeatureContext.php with your own steps.

  • Edit behat.yml and set path parameter under default key to "features: '../all/tests/features'" (so it points to your features dir).

  • Run behat from Drupal docroot with "config" param pointing to your behat.yml: behat --config sites/all/tests/behat.yml (or run behat from sites/default where your behat.yml resides).

So, you keep behat bins at /opt, your tests in sites/all (tests should be the same for all sites: dev workstations, staging, etc), and behat conf at sites/default (so it can be customized for each box).

I think this recipe (or an improved version) may be added to Drupal Extesion module help notes.

EDIT: I've added bootstrap dir info.

Awesome notes

sethcohn's picture

Thank you!

Drupal Extension Documentation

eliza411's picture

I've been working on a Drupal Extension training for a client, and I've put together some materials that might help people more easily evaluate the module that meets their needs:

http://dspeak.com/drupalextension/

It's unclear right now whether this will ultimately live on drupal.org or behat.org so I'm just keeping it in the easiest place for me to maintain right now.

Nice!

tunic's picture

This is a good documentation for Drupal Extension, much needed, thank you very much.

Drupal, Behat and Travis CI

nlisgo's picture

Please consider taking a look at this github project: https://github.com/nlisgo/drupal-kickstart-behat

This is a fork of a repo put together by one of the developers at Capgemini. This is a proof of concept project to show how to integrate Travis CI automated builds and testing into your workflow. Travis CI is free for open source and public projects. That means you can fork my project and monitor your project on Travis CI on every push to the repository.

For this project the site that is being built and tested is commerce kickstart.

I am using the Drupal API driver for this project as it does a great job of creating content and users on the fly so that expectations about behaviour can be more easily verified.

I want to reiterate that although I have put some time into this the major bulk of the work was done by Graham Taylor (tayzlor). But his project had not been updated in a while and I wanted to strip out the saucelabs integrate that he introduced but I have no need for right now.

I hope some of you have a good experience with this. I hope to put together a short video tutorial to support the documentation.

Panopoly also uses Behat and Travis-CI

dsnopek's picture

That looks really cool! Thanks for sharing. :-)

The Panopoly project (a Drupal distribution) also uses Behat on Travis-CI for its continuous integration. If anyone is interested in looking at it as an example (or copying stuff from it), all the Behat stuff is here:

http://drupalcode.org/project/panopoly.git/tree/refs/heads/7.x-1.x:/test...

Here is the .travis.yml which tells Travis-CI what to do on commit:

http://drupalcode.org/project/panopoly.git/blob/refs/heads/7.x-1.x:/.tra...

And here you can see the most recent builds on Travis-CI:

https://travis-ci.org/lsolesen/panopoly/builds
(NOTE: There was a string of errored builds recently as we worked out our upgrade tests)

Anyway, I hope that's helpful for someone!

Thanks for sharing.

nlisgo's picture

Thanks for sharing.

Behat

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: