SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
IT’S ALL ABOUT BEHAVIOUR
-ALSO IN PHP@liuggio
PUG-ROMA 26-02-2013
WHY WE DO TESTS?

> refactor
> automation
> verification
> ??
WHO LOVES TDD?
"Test-Driven Development is a developer practice
that involves writing tests before writing the code
being tested."

<<TDD is a design tool
used to deliver high-quality code >>

REFACTOR IS TIME CONSUMING
TDD: THE INFINTE CYCLE

RED

GREEN

REFACTOR
TDD: THE INFINTE CYCLE
"Run it, watch it fail, write just enough
code to get it to pass, review the design,
and remove duplication" > "Run it, watch it
fail, write just enough code to get it to pass,
review the design, and remove duplication" >
"Run it, watch it fail, write just enough code to get it to pass,
review the design, and remove duplication" > "Run it, watch it fail,
write just enough code to get it to pass, review the design, and remove
duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and
remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove
duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just
enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough
code to get it to pass, review the design, and remove duplication"

TECHNOLOGIC
TDD: mmm
If you have a blank project, you have to start...
Where to start?
What to test?
What not to test?
How much tests?
Where to start?
TDD: mmmmmmmmm
“If you need to test the insertion of an object into a
collection and the collection is represented by an
Array, with xUnit you should assert that the
collection contains the object in the Array, but if the
collection will change to another type of container,
graph for example, the xUnit will fail, even if the
behaviour is unchanged. “
BDD :)
in BDD you are not testing
you are describing what that classes will do,
so you can continue creating the class
Specify the Behaviour by Examples
not testing a class.
BDD :D
External behaviour - Story
Behat deals to have specifications that reflects
the environment from the outside.
Solve: Where to start, What to and not to test
Internal behaviour - Example
PHPSpec responds to the behaviour in the lower
level, from the internal of the classes.
Solve all the TDD mmmmmmm
BDD the double cycle
1 start from Scenario
2 write a story that fail
go to phpspec2 internal level

3 write a fail Example
4 get it green
5 refactor
go to behat external level

7 refactor
"Spec BDD with phpspec
phpspec is a development tool, designed to help you achieve
clean and working PHP code by using a technique derived
from test-first development called (spec) behaviour driven
developement, or SpecBDD."
LET’S CODE
1. Installation composer

{
"require-dev": {
"phpspec/phpspec2": "*"
},
"config": {
"bin-dir": "bin"
},
"autoload": {"psr-0": {"": "src"}},
"minimum-stability": "dev"
}

2.

Code the behaviour: WAIT
we have to talk the same language
DEFINITION
In BDD you are going to 'Describe' the behaviour of a Class
creating a `Spec` that will contain more Examples.
'example' is the class to write, before write the subject code.
'expectation' the behaviour that the subject code should
have.

• Assertion becomes expectation.
• Test method becomes code example
• Test case becomes example group/Specification
CODING TIME
Not really coding, command lining :)
$ bin/phpspec desc FakeTwitter
Specification for FakeTwitter created in spec/FakeTwitter.php.

Now Code the examples ...
$ bin/phpspec run -v -f prettify
BDD
I Code, than I specify

BDD you're doing it wrong
Cool I'm going to
specify all my old
projects

BDD you're doing it wrong
I don't care about
documentation and
acceptance.

BDD you're doing it wrong
I don't need unit tests,
and I do not need to
specify

1987 developer
REFERENCES
- http://www.slideshare.net/bmabey/the-why-behind-tddbdd-and-the-how-with-rspec
- The RSpec Book: Behaviour-Driven Development with RSpec, Cucumber, and Friends
- http://www.slideshare.net/Robbert/bdd-rspec
- phpspec.net
- behat.org

Más contenido relacionado

La actualidad más candente

Integration of automation framework with ci tools
Integration of automation framework with ci toolsIntegration of automation framework with ci tools
Integration of automation framework with ci toolsvodQA
 
Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Peter Kofler
 
Why and how to keep your code quality
Why and how to keep your code quality Why and how to keep your code quality
Why and how to keep your code quality Krešimir Antolić
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?QATestLab
 
Typescript kata The TDD style 2 edition
Typescript kata The TDD style 2 editionTypescript kata The TDD style 2 edition
Typescript kata The TDD style 2 editionRonnie Hegelund
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEGavin Pickin
 
Detangling Your JavaScript
Detangling Your JavaScriptDetangling Your JavaScript
Detangling Your JavaScriptChris Powers
 
Javascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end DevsJavascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end DevsChris Powers
 
Acceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot FrameworkAcceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot FrameworkSteve Zhang
 
Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMSagar Sane
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019Paulo Clavijo
 
Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go langAmal Mohan N
 
C++ and Software Engineering 2015
C++ and Software Engineering 2015C++ and Software Engineering 2015
C++ and Software Engineering 2015Juraj Michálek
 
Dsl로 만나는 groovy
Dsl로 만나는 groovyDsl로 만나는 groovy
Dsl로 만나는 groovySeeyoung Chang
 
Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)Aaron Schlesinger
 

La actualidad más candente (20)

Integration of automation framework with ci tools
Integration of automation framework with ci toolsIntegration of automation framework with ci tools
Integration of automation framework with ci tools
 
Code Quality
Code QualityCode Quality
Code Quality
 
Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)
 
Behavior Driven GUI Testing
Behavior Driven GUI TestingBehavior Driven GUI Testing
Behavior Driven GUI Testing
 
Why and how to keep your code quality
Why and how to keep your code quality Why and how to keep your code quality
Why and how to keep your code quality
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Typescript kata The TDD style 2 edition
Typescript kata The TDD style 2 editionTypescript kata The TDD style 2 edition
Typescript kata The TDD style 2 edition
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
 
Detangling Your JavaScript
Detangling Your JavaScriptDetangling Your JavaScript
Detangling Your JavaScript
 
Javascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end DevsJavascript Tests with Jasmine for Front-end Devs
Javascript Tests with Jasmine for Front-end Devs
 
Acceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot FrameworkAcceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot Framework
 
BDD & Cucumber
BDD & CucumberBDD & Cucumber
BDD & Cucumber
 
Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEM
 
TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
DDD with Behat
DDD with BehatDDD with Behat
DDD with Behat
 
Introduction to go lang
Introduction to go langIntroduction to go lang
Introduction to go lang
 
C++ and Software Engineering 2015
C++ and Software Engineering 2015C++ and Software Engineering 2015
C++ and Software Engineering 2015
 
Dsl로 만나는 groovy
Dsl로 만나는 groovyDsl로 만나는 groovy
Dsl로 만나는 groovy
 
Why I Love Ruby On Rails
Why I Love Ruby On RailsWhy I Love Ruby On Rails
Why I Love Ruby On Rails
 
Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)
 

Similar a It's all about behaviour, also in php - phpspec

Don't let your tests slow you down
Don't let your tests slow you downDon't let your tests slow you down
Don't let your tests slow you downDaniel Irvine
 
Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testingdn
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testingmalcolmt
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is ImportaintSana Nasar
 
BDD style Unit Testing
BDD style Unit TestingBDD style Unit Testing
BDD style Unit TestingWen-Tien Chang
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012Pietro Di Bello
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - GreachHamletDRC
 
Agile JavaScript Testing
Agile JavaScript TestingAgile JavaScript Testing
Agile JavaScript TestingScott Becker
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF SummitOrtus Solutions, Corp
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumberDaniel Kummer
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD WorkshopWolfram Arnold
 
BDD Testing and Automating from the trenches - Presented at Into The Box June...
BDD Testing and Automating from the trenches - Presented at Into The Box June...BDD Testing and Automating from the trenches - Presented at Into The Box June...
BDD Testing and Automating from the trenches - Presented at Into The Box June...Gavin Pickin
 
ITB2016 -BDD testing and automation from the trenches
ITB2016 -BDD testing and automation from the trenchesITB2016 -BDD testing and automation from the trenches
ITB2016 -BDD testing and automation from the trenchesOrtus Solutions, Corp
 
TDD and BDD in Sky Deutschland
TDD and BDD in Sky DeutschlandTDD and BDD in Sky Deutschland
TDD and BDD in Sky DeutschlandMurphy Meng
 
Spec(ing) Out Your Workflow with SpecFlow
Spec(ing) Out Your Workflow with SpecFlowSpec(ing) Out Your Workflow with SpecFlow
Spec(ing) Out Your Workflow with SpecFlowSarah Dutkiewicz
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Brian Sam-Bodden
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratiehcderaad
 

Similar a It's all about behaviour, also in php - phpspec (20)

Don't let your tests slow you down
Don't let your tests slow you downDon't let your tests slow you down
Don't let your tests slow you down
 
Behaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About TestingBehaviour Driven Development and Thinking About Testing
Behaviour Driven Development and Thinking About Testing
 
Bdd and-testing
Bdd and-testingBdd and-testing
Bdd and-testing
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is Importaint
 
BDD style Unit Testing
BDD style Unit TestingBDD style Unit Testing
BDD style Unit Testing
 
TDD a piccoli passi
TDD a piccoli passiTDD a piccoli passi
TDD a piccoli passi
 
TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - Greach
 
Agile JavaScript Testing
Agile JavaScript TestingAgile JavaScript Testing
Agile JavaScript Testing
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumber
 
Tdd in practice
Tdd in practiceTdd in practice
Tdd in practice
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop
 
BDD Testing and Automating from the trenches - Presented at Into The Box June...
BDD Testing and Automating from the trenches - Presented at Into The Box June...BDD Testing and Automating from the trenches - Presented at Into The Box June...
BDD Testing and Automating from the trenches - Presented at Into The Box June...
 
ITB2016 -BDD testing and automation from the trenches
ITB2016 -BDD testing and automation from the trenchesITB2016 -BDD testing and automation from the trenches
ITB2016 -BDD testing and automation from the trenches
 
TDD and BDD in Sky Deutschland
TDD and BDD in Sky DeutschlandTDD and BDD in Sky Deutschland
TDD and BDD in Sky Deutschland
 
Spec(ing) Out Your Workflow with SpecFlow
Spec(ing) Out Your Workflow with SpecFlowSpec(ing) Out Your Workflow with SpecFlow
Spec(ing) Out Your Workflow with SpecFlow
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie
 

Más de Giulio De Donato

Docker italia fatti un container tutto tuo
Docker italia fatti un container tutto tuoDocker italia fatti un container tutto tuo
Docker italia fatti un container tutto tuoGiulio De Donato
 
Lets isolate a process with no container like docker
Lets isolate a process with no container like dockerLets isolate a process with no container like docker
Lets isolate a process with no container like dockerGiulio De Donato
 
More developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestrationMore developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestrationGiulio De Donato
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microserviceGiulio De Donato
 
Json web token api authorization
Json web token api authorizationJson web token api authorization
Json web token api authorizationGiulio De Donato
 
Think horizontally ood, ddd and bdd
Think horizontally ood, ddd and bddThink horizontally ood, ddd and bdd
Think horizontally ood, ddd and bddGiulio De Donato
 
I came i saw i go - golang it meetup codemotion rome 2014
I came i saw i go - golang it meetup codemotion rome 2014I came i saw i go - golang it meetup codemotion rome 2014
I came i saw i go - golang it meetup codemotion rome 2014Giulio De Donato
 
Benchmark Profile and Boost your Symfony application
Benchmark Profile and Boost your Symfony applicationBenchmark Profile and Boost your Symfony application
Benchmark Profile and Boost your Symfony applicationGiulio De Donato
 
Leaphly fight monolothic today
Leaphly fight monolothic todayLeaphly fight monolothic today
Leaphly fight monolothic todayGiulio De Donato
 
Design pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesDesign pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesGiulio De Donato
 
Caching and data analysis will move your Symfony2 application to the next level
Caching and data analysis will move your Symfony2 application to the next levelCaching and data analysis will move your Symfony2 application to the next level
Caching and data analysis will move your Symfony2 application to the next levelGiulio De Donato
 
Rationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoringRationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoringGiulio De Donato
 

Más de Giulio De Donato (12)

Docker italia fatti un container tutto tuo
Docker italia fatti un container tutto tuoDocker italia fatti un container tutto tuo
Docker italia fatti un container tutto tuo
 
Lets isolate a process with no container like docker
Lets isolate a process with no container like dockerLets isolate a process with no container like docker
Lets isolate a process with no container like docker
 
More developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestrationMore developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestration
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
Json web token api authorization
Json web token api authorizationJson web token api authorization
Json web token api authorization
 
Think horizontally ood, ddd and bdd
Think horizontally ood, ddd and bddThink horizontally ood, ddd and bdd
Think horizontally ood, ddd and bdd
 
I came i saw i go - golang it meetup codemotion rome 2014
I came i saw i go - golang it meetup codemotion rome 2014I came i saw i go - golang it meetup codemotion rome 2014
I came i saw i go - golang it meetup codemotion rome 2014
 
Benchmark Profile and Boost your Symfony application
Benchmark Profile and Boost your Symfony applicationBenchmark Profile and Boost your Symfony application
Benchmark Profile and Boost your Symfony application
 
Leaphly fight monolothic today
Leaphly fight monolothic todayLeaphly fight monolothic today
Leaphly fight monolothic today
 
Design pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentesDesign pattern in Symfony2 - Nanos gigantium humeris insidentes
Design pattern in Symfony2 - Nanos gigantium humeris insidentes
 
Caching and data analysis will move your Symfony2 application to the next level
Caching and data analysis will move your Symfony2 application to the next levelCaching and data analysis will move your Symfony2 application to the next level
Caching and data analysis will move your Symfony2 application to the next level
 
Rationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoringRationally boost your symfony2 application with caching tips and monitoring
Rationally boost your symfony2 application with caching tips and monitoring
 

Último

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

It's all about behaviour, also in php - phpspec

  • 1. IT’S ALL ABOUT BEHAVIOUR -ALSO IN PHP@liuggio PUG-ROMA 26-02-2013
  • 2. WHY WE DO TESTS? > refactor > automation > verification > ??
  • 3. WHO LOVES TDD? "Test-Driven Development is a developer practice that involves writing tests before writing the code being tested." <<TDD is a design tool used to deliver high-quality code >> REFACTOR IS TIME CONSUMING
  • 4. TDD: THE INFINTE CYCLE RED GREEN REFACTOR
  • 5. TDD: THE INFINTE CYCLE "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" > "Run it, watch it fail, write just enough code to get it to pass, review the design, and remove duplication" TECHNOLOGIC
  • 6. TDD: mmm If you have a blank project, you have to start... Where to start? What to test? What not to test? How much tests? Where to start?
  • 7. TDD: mmmmmmmmm “If you need to test the insertion of an object into a collection and the collection is represented by an Array, with xUnit you should assert that the collection contains the object in the Array, but if the collection will change to another type of container, graph for example, the xUnit will fail, even if the behaviour is unchanged. “
  • 8. BDD :) in BDD you are not testing you are describing what that classes will do, so you can continue creating the class Specify the Behaviour by Examples not testing a class.
  • 9. BDD :D External behaviour - Story Behat deals to have specifications that reflects the environment from the outside. Solve: Where to start, What to and not to test Internal behaviour - Example PHPSpec responds to the behaviour in the lower level, from the internal of the classes. Solve all the TDD mmmmmmm
  • 10. BDD the double cycle 1 start from Scenario 2 write a story that fail go to phpspec2 internal level 3 write a fail Example 4 get it green 5 refactor go to behat external level 7 refactor
  • 11. "Spec BDD with phpspec phpspec is a development tool, designed to help you achieve clean and working PHP code by using a technique derived from test-first development called (spec) behaviour driven developement, or SpecBDD."
  • 12. LET’S CODE 1. Installation composer { "require-dev": { "phpspec/phpspec2": "*" }, "config": { "bin-dir": "bin" }, "autoload": {"psr-0": {"": "src"}}, "minimum-stability": "dev" } 2. Code the behaviour: WAIT we have to talk the same language
  • 13. DEFINITION In BDD you are going to 'Describe' the behaviour of a Class creating a `Spec` that will contain more Examples. 'example' is the class to write, before write the subject code. 'expectation' the behaviour that the subject code should have. • Assertion becomes expectation. • Test method becomes code example • Test case becomes example group/Specification
  • 14. CODING TIME Not really coding, command lining :) $ bin/phpspec desc FakeTwitter Specification for FakeTwitter created in spec/FakeTwitter.php. Now Code the examples ... $ bin/phpspec run -v -f prettify
  • 15. BDD
  • 16. I Code, than I specify BDD you're doing it wrong
  • 17. Cool I'm going to specify all my old projects BDD you're doing it wrong
  • 18. I don't care about documentation and acceptance. BDD you're doing it wrong
  • 19. I don't need unit tests, and I do not need to specify 1987 developer
  • 20. REFERENCES - http://www.slideshare.net/bmabey/the-why-behind-tddbdd-and-the-how-with-rspec - The RSpec Book: Behaviour-Driven Development with RSpec, Cucumber, and Friends - http://www.slideshare.net/Robbert/bdd-rspec - phpspec.net - behat.org