Behat/Drupal Workshop

Behavior-Driven Development for Drupal with Behat

Behat

"Bee-Hat" [image source: "Männer in Harnisch" by Jiří Winter Neprakta; Artia, Prague © 1972 ]

What It Is

How To Use It

  1. Write your user stories ( Features and Scenarios ) in a human-readable format ( Gerkin language ).

    Feature: Some terse yet descriptive text of what is desired
    In order to realize a named business value
    As an explicit system actor
    I want to gain some beneficial outcome which furthers the goal
    
    Scenario: Some determinable business situation
    Given some precondition
    And some other precondition
    When some action by the actor
    And some other action
    And yet another action
    Then some testable outcome is achieved
    And something else we can check happens too
    
  2. Back up your stories with code (Step Definitions).

    <?php
      /**
       * @Then /^some testable outcome is achieved$/
       */
      public function assertSomeTestableOutcomeIsAchieved() {
        // make your assertion here,
        // if it fails throw an exception
      }
    
  3. Run it.

The Stack