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 http://www.behat.org.

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 live online training, plus books, videos, and digital content from nearly 200 publishers.