I am proud to announce the release of the Behat Drupal Extension 3.0! Since 2012, the Drupal Extension has been used for Behaviour Driven Development of thousands of Drupal sites all over the world. The project began as part of the Drupal.org upgrade, and was quickly generalized to enable the testing of any Drupal site.
Version 3 has many exciting new features, and is compatible with Behat 3. Note version 2 does not exist, wanting to avoid version soup.
Behavior Driven Development at BADCamp
Before I dive into the new features, it is important to clarify the difference between testing an application, and Behavior Driven Development (BDD).
- When browsing an article
- Should be able to see related articles
rather, it starts with a conversation
- In order to read more interesting articles
- As a reader
- I need to see related articles to the one I'm reading
While both are testing something, only the latter is truly describing a behavior that matters to a stakeholder. This is the subject of a blog post, or series of posts, in and of itself, so more on this subject later.
A starter context
A starter Drupal context that makes no assumptions around the language used for each test, but still provides all the previous functionality to interact directly with Drupal.
Users are encouraged to start tests from this context which will allow them to use truly ubiquitous language that is specific to each project.
The Drupal Drivers now exist in a separate project, allowing for non-Behat applications to interact with Drupal (e.g., calling directly from Mink, or Codeception).
Note that the Drupal 6 driver has been removed, but since drivers are now separate projects, it will be easy to port that over to the Drupal Extension 3, should somebody want.
It should also be noted that Drupal 8 support will require ongoing work as the code base there evolves towards release.
More granular pre-defined step-definitions
Existing step definitions have been split into 4 indepentent contexts:
DrupalContext- This contains steps for working with content, users, and taxonomies.
MinkContext- This is an extension to the Mink Extension, providing additional steps for working with regions and forms.
MessageContext- Provides steps for working with Drupal success/warning/error messages.
DrushContext- Provides steps for calling drush commands directly from scenarios
This allows for the use of some pre-definied step-definitions, rather than the previous all-or-none approach.
No more regex!
The pre-definied steps now use the new turnip syntax introduced in Behat 3:
Given I am viewing a/an :type (content )with the title :title
Given /^(?:a|an) "(?P<type>[^"]*)" node with the title "(?P<title>[^"]*)"$/
What's a 'node'?!
The term node has been removed from steps and replaced with content in all pre-defined steps.
- A REST driver that would allow the full power of the Drupal API to be utilized from a remote server.
- Testing Drupal core with Mink and the Drupal Drivers?
BDD Mini Summit
I will be attending the Behat mini-summit at BADCamp along with several other folks from Phase 2. I hope to highlight the Drupal Extension 3, and discuss best-practices for the wide variety of testing needs. I also hope to continue discussions around Behat, Mink and Drupal core.