BDD + PHP = Behat

Łukasz Kużyński – wookieb
@wookiebpl
http://wookieb.pl
What is BDD
●   BDD = Behavior Driven Development
●   technique for testing and develop software
●   agile software development technique
●   variant of TDD
●   bridge between programmer and client
What is BDD




        Is a state of mind *




* http://blog.robustsoftware.co.uk/2009/11/what-is-bdd-behaviour-driven-design.html
BDD in PHP
How Behat's tests looks like
Behat scenario schema
Behat scenario - example
Behat - FeatureContext
Behat – First run (with our code)
Same scenario with new values
Scenario Outline
Feature Background




Executed before each scenario
Hooks
Mooore hooks
BeforeSuite   BeforeFeature   BeforeaScenario   BeforeStep
AfterSuite    AfterFeature    AfterScenario     AfterStep
Given, When, Then
●   No special meaning in code
●   Just a possibility to mark steps
●   Increase readability of FeatureContext
Extend FeatureContext




Substitute for „horizontal inheritance”
Useful contexts




https://github.com/Behat/CommonContexts
Pitfalls




Feature should be written for humans,
not programmers



              http://elabs.se/blog/15-you-re-cuking-it-wrong
Can i write „unit tests” in BDD?




         It is possible but ...
               inefficient
Does BDD is a replacement
  for my standard tests


         Questions?
Łukasz Kużyński – wookieb
@wookiebpl
http://wookieb.pl

BDD in PHP - Behat