TDD💙BDD💙PHP
Patrick Luca Fazzi
Developer
Legacy code
High coupling
Anti-patterns
Absent
documentationBugs
Spaghetti code
Test-Driven Development
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
TDD… What do you need to do?
1. Red - Write a little test that doesn’t work, and perhaps
doesn’t even compile at first.
2. Green - Make the test work quickly, committing
whatever sins necessary in the process.
3. Refactor - Eliminate all the duplication created in
merely getting the test to work.
Benefits of TDD
1. Cleaner, better designed code
2. Code that’s easier and less expensive to maintain
3. Fewer bugs from the outset
4. A comprehensive set of regression tests
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
We want to build software well...
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
We want to build software well…
bu we also need to build software that’s
worth building!
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
Behaviour-Driven Development
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
Behaviour-Driven Development
● BDD was originally designed as an improved version of
TDD.
● It is a set of software engineering practices designed to
help teams build and deliver more valuable, higher quality
software faster.
● BDD aims to facilitate the communication between software
development teams and business stakeholders.
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
BDD Tools And Practices
Feature Injection
Impact Mapping
Purpose-Based Alignment Model
Features and User Stories
Gherkin
StoryBDD
SpecBDD
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
BDD Tools And Practices
Feature Injection
Impact Mapping
Purpose-Based Alignment Model
Features and User Stories
Gherkin
StoryBDD
SpecBDD
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
A php toolset to drive emergent
design by specification.
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
Fizz Buzz Kata
Write a program that converts numbers according to the following rules:
● For multiples of three print Fizz instead of the number
● For the multiples of five print Buzz instead of the number
● For numbers which are multiples of both three and five print FizzBuzz instead of the
number
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
Prophet Objects
1. class FizzBuzzSpec extends ObjectBehavior
2. {
3. function let(Logger $logger)
4. {
5. $this->beConstructedWith($logger);
6. }
7.
8. function it_logs_numbers(Logger $logger)
9. {
10. $this->convert(85);
11.
12. $logger->log(85)->shouldHaveBeenCalledOnce();
13. }
14. }
Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
“An expert is a person who has made all the mistakes that
can be made in a very narrow field.”
(Niels Bohr)
Twitter: https://twitter.com/CataniaPug
Web: https://catania.grusp.org/
Meetup: https://www.meetup.com/it-IT/pugCatania-PHP-User-Group-Catania/
Thank you!!!
Code: https://github.com/pfazzi/fizz-buzz-kata
JoindIn: https://joind.in/talk/9b99d
Patrick Luca Fazzi | Developer @ FLOWING
Twitter: https://twitter.com/PatrickFazzi
LinkedIn: https://www.linkedin.com/in/patrickfazzi

TDD BDD PHP - Sviluppo guidato dai test in PHP con phpspec

  • 1.
  • 2.
  • 3.
    Test-Driven Development Hai domande?Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 4.
    TDD… What doyou need to do? 1. Red - Write a little test that doesn’t work, and perhaps doesn’t even compile at first. 2. Green - Make the test work quickly, committing whatever sins necessary in the process. 3. Refactor - Eliminate all the duplication created in merely getting the test to work.
  • 5.
    Benefits of TDD 1.Cleaner, better designed code 2. Code that’s easier and less expensive to maintain 3. Fewer bugs from the outset 4. A comprehensive set of regression tests Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 6.
    We want tobuild software well... Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 7.
    We want tobuild software well… bu we also need to build software that’s worth building! Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 8.
    Behaviour-Driven Development Hai domande?Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 9.
    Behaviour-Driven Development ● BDDwas originally designed as an improved version of TDD. ● It is a set of software engineering practices designed to help teams build and deliver more valuable, higher quality software faster. ● BDD aims to facilitate the communication between software development teams and business stakeholders. Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 10.
    BDD Tools AndPractices Feature Injection Impact Mapping Purpose-Based Alignment Model Features and User Stories Gherkin StoryBDD SpecBDD Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 11.
    BDD Tools AndPractices Feature Injection Impact Mapping Purpose-Based Alignment Model Features and User Stories Gherkin StoryBDD SpecBDD Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 12.
    A php toolsetto drive emergent design by specification. Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 13.
    Fizz Buzz Kata Writea program that converts numbers according to the following rules: ● For multiples of three print Fizz instead of the number ● For the multiples of five print Buzz instead of the number ● For numbers which are multiples of both three and five print FizzBuzz instead of the number Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 14.
    Prophet Objects 1. classFizzBuzzSpec extends ObjectBehavior 2. { 3. function let(Logger $logger) 4. { 5. $this->beConstructedWith($logger); 6. } 7. 8. function it_logs_numbers(Logger $logger) 9. { 10. $this->convert(85); 11. 12. $logger->log(85)->shouldHaveBeenCalledOnce(); 13. } 14. } Hai domande? Scrivile su Sli.do inserendo il codice #phpdayPUGed
  • 15.
    “An expert isa person who has made all the mistakes that can be made in a very narrow field.” (Niels Bohr)
  • 16.
    Twitter: https://twitter.com/CataniaPug Web: https://catania.grusp.org/ Meetup:https://www.meetup.com/it-IT/pugCatania-PHP-User-Group-Catania/ Thank you!!! Code: https://github.com/pfazzi/fizz-buzz-kata JoindIn: https://joind.in/talk/9b99d Patrick Luca Fazzi | Developer @ FLOWING Twitter: https://twitter.com/PatrickFazzi LinkedIn: https://www.linkedin.com/in/patrickfazzi