Full stack BDD for Symfony2

29
Full Stack BDD for Symfony2 Marcello Duarte Konstantin Kudryashov

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 of Full stack BDD for Symfony2

Page 1: Full stack BDD for Symfony2

Full Stack BDD for Symfony2

Marcello DuarteKonstantin Kudryashov

Page 2: Full stack BDD for Symfony2

Marcello DuarteHead of Training

Konstantin KudryashovLead Developer

About us

Page 3: Full stack BDD for Symfony2

• Where are we coming from

• Why BDD

• Behat Best Practices

• Introducing a new tool

This talk

Page 4: Full stack BDD for Symfony2

fromCucumber to

Page 5: Full stack BDD for Symfony2
Page 6: Full stack BDD for Symfony2

Adults don’t think their way into a new

way of acting

Page 7: Full stack BDD for Symfony2

They act their way into a new way of

thinking

Adults don’t think their way into a new

way of acting

Page 8: Full stack BDD for Symfony2

Ask Why

Page 9: Full stack BDD for Symfony2

PHPSpec

from xUnit to xSpec

Page 10: Full stack BDD for Symfony2

Test

? ???

? ? ?

?

??

?

?

?

?

?

?

? ?

Page 11: Full stack BDD for Symfony2

xUnit

assert

code coverage

structure

private

database mocking

Page 12: Full stack BDD for Symfony2

Language matter

Page 13: Full stack BDD for Symfony2

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);

Page 14: Full stack BDD for Symfony2

Tools matter

Page 15: Full stack BDD for Symfony2

Why BDD?

Page 16: Full stack BDD for Symfony2

[Royce 1970]

Requirements

Analysis

Design

Develop

Test

9 months 3 months 2 months 12 months ...

Page 17: Full stack BDD for Symfony2

Most of the cost in software development

is infeedback delay

Page 18: Full stack BDD for Symfony2

Refactoring

Code

Test

Requirements

Acceptance

~20 minutes

[Beck & Cunningham 1996-99]

Page 19: Full stack BDD for Symfony2

Let’s reduce feedback delay

Page 20: Full stack BDD for Symfony2

Let’s rename a few things

Page 21: Full stack BDD for Symfony2

Incremental Design

Implement

Describe Object

Narratives (Why?)

Examples (What do you

mean?)

How!

[North 03]

Page 22: Full stack BDD for Symfony2
Page 23: Full stack BDD for Symfony2

Building a simple

Student can enrol on a course

feature

Page 24: Full stack BDD for Symfony2

You can follow our steps

http://git.io/t4kQ5Q

Page 25: Full stack BDD for Symfony2

• 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

Page 26: Full stack BDD for Symfony2

• Favour MinkAwareInterface over MinkContext

• Extract context per role

• Group features under feature folder

• Use Mink API

• Integrate with framework at config level

Behat tips

Page 27: Full stack BDD for Symfony2

• Describe classes not configuration

• Concentrate on messages/behaviours

PHPSpec2 tips

Page 28: Full stack BDD for Symfony2

Questions

? ???

? ? ?

?

??

?

?

?

?

?

?

? ?

Page 29: Full stack BDD for Symfony2

joind.in/7064

Thanks! :)