Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Behat & PhpSpec workshop

Behat & PhpSpec workshop

Avatar for Pierre Ferré

Pierre Ferré

June 23, 2015

Other Decks in Technology

Transcript

  1. What is BDD? • It’s simply test driven development, but

    with a twist • Focuses on “behaviour” rather than the “how” to build software • Feels more natural • Think about the feature and describe the behaviour
  2. Given, When, Then • State machine transitions • Finite State

    Machine • Given the system is in some state • When some event is triggered • Then we expect some outcome
  3. Behat • Ported to PHP from ruby Cucumber by @everzet

    (Konstantin Kudryashov) • Uses Gherkin as BRDSL (Business Readable Domain Specific Language) • BRDSL is also used by cucumber • Is used to describe the behaviour of your application from the outside in
  4. PhpSpec • Drives the design of your classes by describing

    their behaviour • It is at unit level • For example, a parser. You would drive the design of a Parser class by describing what it should do. • Not the same as testing from the outside in
  5. Example Feature Scenario Feature: Authenticate users In order to allow

    users to access the site’s admin As a system user We need to have a mechanism to authenticate the user Scenario: Login user Given there is an entry for user “john.doe@worldstores” When I sign in as “john.doe@worldstores” Then I should be signed in
  6. Supported material “What’s in a story?” Dan North - Link

    The truth about BDD, Robert C. Martin - Link Cucumber - Link Gherkin - Link Behat on Github - Link PhpSpec - Link Dan North, “What’s In a Story?” - Link Behat Configuration options - Link “Classic” TDD vs “London school” TDD - Link
  7. Few books • Growing object oriented software guided by tests

    - http://www.growing-object-oriented- software.com/ • Refactoring, by Martin Fowler - Link