Behavior-Driven Development

BDD works by implementing tests using human-readable stories.

Cucumber is a tool that implements a BDD workflow by using human-readable feature files written in plain English language, for example:

Feature: Log in to site. 
  In order to see my profile 
    As a user 
    I need to log-in to the site. 
Scenario: Logs in to the site 
  Given I am on "/" 
  When I follow "Log In" 
    And I fill in "Username" with "admin" 
    And I fill in "Password" with "test" 
    And I press "Log in" 
  Then I should see "Log out" 
    And I should see "My account" 

Now, this section is going to be an incredibly simple exploration of Behat to pique your curiosity. If you want to learn more, please head to

The Behat guide contains an example of a user story ...

Get Mastering PHP Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.