Slide 1

Slide 1 text

Full Stack BDD for Symfony2 Marcello Duarte Konstantin Kudryashov

Slide 2

Slide 2 text

Marcello Duarte Head of Training Konstantin Kudryashov Lead Developer About us

Slide 3

Slide 3 text

• Where are we coming from • Why BDD • Behat Best Practices • Introducing a new tool This talk

Slide 4

Slide 4 text

from Cucumber to

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Adults don’t think their way into a new way of acting

Slide 7

Slide 7 text

They act their way into a new way of thinking Adults don’t think their way into a new way of acting

Slide 8

Slide 8 text

Ask Why

Slide 9

Slide 9 text

PHPSpec from xUnit to xSpec

Slide 10

Slide 10 text

Test ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

Slide 11

Slide 11 text

xUnit assert code coverage structure private database mocking

Slide 12

Slide 12 text

Language matter

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

Tools matter

Slide 15

Slide 15 text

Why BDD?

Slide 16

Slide 16 text

[Royce 1970] Requirements Analysis Design Develop Test 9 months 3 months 2 months 12 months ...

Slide 17

Slide 17 text

Most of the cost in software development is in feedback delay

Slide 18

Slide 18 text

Refactoring Code Test Requirements Acceptance ~20 minutes [Beck & Cunningham 1996-99]

Slide 19

Slide 19 text

Let’s reduce feedback delay

Slide 20

Slide 20 text

Let’s rename a few things

Slide 21

Slide 21 text

Incremental Design Implement Describe Object Narratives (Why?) Examples (What do you mean?) How! [North 03]

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Building a simple Student can enrol on a course feature

Slide 24

Slide 24 text

You can follow our steps http://git.io/t4kQ5Q

Slide 25

Slide 25 text

• 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

Slide 26

Slide 26 text

• Favour MinkAwareInterface over MinkContext • Extract context per role • Group features under feature folder • Use Mink API • Integrate with framework at config level Behat tips

Slide 27

Slide 27 text

• Describe classes not configuration • Concentrate on messages/behaviours PHPSpec2 tips

Slide 28

Slide 28 text

Questions ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

Slide 29

Slide 29 text

joind.in/7064 Thanks! :)