full stack bdd for symfony2
DESCRIPTION
Many Symfony2 developers have heard about Behat and even use it regularly in their Symfony projects. If you have found value in this tool and the BDD practices it was inspired on, come join us for this talk as we will expand on what other benefits these practices and other BDD tools available can bring. This very illustrative talk will not only present you with the tools but show how to use them together to build beautifully architected, business-oriented Symfony2 applications.TRANSCRIPT
Full Stack BDD for Symfony2
Marcello DuarteKonstantin Kudryashov
Marcello DuarteHead of Training
Konstantin KudryashovLead Developer
About us
• Where are we coming from
• Why BDD
• Behat Best Practices
• Introducing a new tool
This talk
fromCucumber to
Adults don’t think their way into a new
way of acting
They act their way into a new way of
thinking
Adults don’t think their way into a new
way of acting
Ask Why
PHPSpec
from xUnit to xSpec
Test
? ???
? ? ?
?
??
?
?
?
?
?
?
? ?
xUnit
assert
code coverage
structure
private
database mocking
Language matter
public function testUpdateWithEqualTypes() { $installer = $this->createInstallerMock(); $manager = new InstallationManager('vendor'); $manager->addInstaller($installer);
$initial = $this->createPackageMock(); $target = $this->createPackageMock(); $operation = new UpdateOperation($initial, $target, 'test');
$initial ->expects($this->once()) ->method('getType') ->will($this->returnValue('library')); $target ->expects($this->once()) ->method('getType') ->will($this->returnValue('library'));
$installer ->expects($this->once()) ->method('supports') ->with('library') ->will($this->returnValue(true));
$installer ->expects($this->once()) ->method('update') ->with($this->repository, $initial, $target);
Tools matter
Why BDD?
[Royce 1970]
Requirements
Analysis
Design
Develop
Test
9 months 3 months 2 months 12 months ...
Most of the cost in software development
is infeedback delay
Refactoring
Code
Test
Requirements
Acceptance
~20 minutes
[Beck & Cunningham 1996-99]
Let’s reduce feedback delay
Let’s rename a few things
Incremental Design
Implement
Describe Object
Narratives (Why?)
Examples (What do you
mean?)
How!
[North 03]
Building a simple
Student can enrol on a course
feature
• No examples until you have a red step
• No code until you have a red example
• No more code than enough to make it green
• Don’t get carried away!
BDD Rules
• Favour MinkAwareInterface over MinkContext
• Extract context per role
• Group features under feature folder
• Use Mink API
• Integrate with framework at config level
Behat tips
• Describe classes not configuration
• Concentrate on messages/behaviours
PHPSpec2 tips
Questions
? ???
? ? ?
?
??
?
?
?
?
?
?
? ?
joind.in/7064
Thanks! :)