What is BDD? Is it the same as TDD, or something quite different? This talk will answer these questions, and show how PhpSpec can be integrated into your development workflow to drive your Object Oriented design. Plus: a sneak peak at some of the new features in the forthcoming 2.1 release.
6. BDD is the art of using
examples in conversation to
illustrate behaviour
1
Liz Keogh
7. Test Driven
Development
4 Before you write your code,
write a test that validates how
it should behave
4 After you have written the
code, see if it passes the test
8. Behaviour Driven
Development
4 Before you write your code,
describe how it should behave
using examples
4 Then, Implement the behaviour
you you described
20. Describing object behaviour
4 We describe an object using a Specification
4 A specification is made up of Examples illustrating
different scenarios
Usage:
phpspec describe [Class]
66. Another example for Greeter:
When this greets Bob, it
should return "Hello, Bob"
67. Describing collaboration - Stubs
Stubs are used to describe how we interact with objects
we query
4 Maybe it is hard to get the real collaborator to
return the value we want
4 Maybe using the real collaborator is expensive
77. Describing collaboration - Mocks and
Spies
Mocks or Spies are used to describe how we interact
with objects we command
4 Maybe the real command is has side effects
4 Maybe using the real collaborator is expensive
89. PhpSpec
4 Focuses on being descriptive
4 Makes common dev activities easier or automated
4 Drives your design
90. 2.1 release - soon!
4 Rerun after failure
4 --fake option
4 Named constructors: User::named('Bob')
4 PSR-4 support (+ other autoloaders)
4 + lots of small improvements
91. Me
4 Senior Trainer at Inviqa / Sensio Labs UK / Session
Digital
4 Contributor to PhpSpec
4 @ciaranmcnulty
4 https://github.com/ciaranmcnulty/phplondon-phpspec-
talk