SlideShare a Scribd company logo
1 of 16
Ferdinando
Santacroce
@JesusWasRasta
TDD a piccoli passi
All’inizio le mie applicazioni
le testavo così...
Vediamo un po’ come funziona...
mmm, pensavo fosse
meno complicato...
Ho capito,
devo usare i mock!
Sì, ma che fatica!
Driven!!
Cos’è TDD?
Scrivi dei test
Scrivi codice fino a
farli passare tutti
Fai un po’ di pulizia
The Three Laws of TDD
1. “You aren’t allowed to write any production code
until you have written a failing unit test”.
2. “You aren’t allowed to write more of a unit test
than is sufficient to fail. And not compiling is
failing.”
3. “You aren’t allowed to write more production code
than is sufficient to pass the currently failing unit
test.”
Ecco cos’è TDD!
Write a single test
that fails
Write code to
make the test pass
Improve the code base
The Three Laws of TDD
1. “You aren’t allowed to write any production code until you have
written a failing unit test”.
2.“You aren’t allowed to write more of a unit test than is sufficient
to fail. And not compiling is failing.”
3. “You aren’t allowed to write more
production code than is sufficient to pass
the currently failing unit test.”
Proviamoci!
See the code on Github:
https://github.com/jesuswasrasta/SmallStepsTDD.git
• Nell’algoritmo non v’è espresso il concetto di numero primo
• Brainlessness (2 -> n)
• I cicli sono una generalizzazione delle if
• Passo dei test nuovi senza modificare codice
• Se immaginiamo i test come feature, che bello sarebbe aggiungere
funzionalità al nostro software con questa facilità?!
• Refactoring: rimuovere duplicazione, rimuovere codice
Cosa si nota?
({}–>nil) no code at all->code that employs nil
(nil->constant)
(constant->constant+) a simple constant to a more complex constant
(constant->scalar) replacing a constant with a variable or an argument
(statement->statements) adding more unconditional statements.
(unconditional->if) splitting the execution path
(scalar->array)
(array->container)
(statement->recursion)
(if->while)
(expression->function) replacing an expression with a function or algorithm
(variable->assignment) replacing the value of a variable.
Transformations
https://8thlight.com/blog/uncle-
bob/2013/05/27/TheTransformationPriorityPremise.html
https://en.wikipedia.org/wiki/Transformation_Priority_Premise
https://www.youtube.com/watch?v=B93QezwTQpI
https://vimeo.com/97516288
https://vimeo.com/60561303
Transformations Priority Premise
Robert C. Martin (Uncle Bob)
@JesusWasRasta
DOmande?
@JesusWasRasta

More Related Content

What's hot

Auto integration testing
Auto integration testingAuto integration testing
Auto integration testing
Arthur Yueh
 

What's hot (8)

Auto integration testing
Auto integration testingAuto integration testing
Auto integration testing
 
Refactoring legacy code driven by tests - ENG
Refactoring legacy code driven by tests - ENGRefactoring legacy code driven by tests - ENG
Refactoring legacy code driven by tests - ENG
 
Learning to Enjoy Unit Testing
Learning to Enjoy Unit TestingLearning to Enjoy Unit Testing
Learning to Enjoy Unit Testing
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With Pytest
 
Obejct Oriented SCM - OOSCM
Obejct Oriented SCM - OOSCMObejct Oriented SCM - OOSCM
Obejct Oriented SCM - OOSCM
 
STAMP, or Test Amplification to DevTestOps service, OW2con'18, June 7-8, 2018...
STAMP, or Test Amplification to DevTestOps service, OW2con'18, June 7-8, 2018...STAMP, or Test Amplification to DevTestOps service, OW2con'18, June 7-8, 2018...
STAMP, or Test Amplification to DevTestOps service, OW2con'18, June 7-8, 2018...
 
Automated testing in Python and beyond
Automated testing in Python and beyondAutomated testing in Python and beyond
Automated testing in Python and beyond
 
TDD in Go with Ginkgo and Gomega
TDD in Go with Ginkgo and GomegaTDD in Go with Ginkgo and Gomega
TDD in Go with Ginkgo and Gomega
 

Viewers also liked

Viewers also liked (7)

Gestione del Product Backlog: un decluttering efficace
Gestione del Product Backlog: un decluttering efficaceGestione del Product Backlog: un decluttering efficace
Gestione del Product Backlog: un decluttering efficace
 
Product Owner - Scopriamo questo sconosciuto!
Product Owner - Scopriamo questo sconosciuto!Product Owner - Scopriamo questo sconosciuto!
Product Owner - Scopriamo questo sconosciuto!
 
Accidenti! Non è command and control! ovvero Stili di leadership in un conte...
Accidenti! Non è command and control! ovvero Stili di leadership in un conte...Accidenti! Non è command and control! ovvero Stili di leadership in un conte...
Accidenti! Non è command and control! ovvero Stili di leadership in un conte...
 
System integration through queues
System integration through queuesSystem integration through queues
System integration through queues
 
Product Lift Off: How to keep everyone on board!
Product Lift Off: How to keep everyone on board!Product Lift Off: How to keep everyone on board!
Product Lift Off: How to keep everyone on board!
 
Agile Data Science
Agile Data ScienceAgile Data Science
Agile Data Science
 
Definition of Ready (XP2011)
Definition of Ready (XP2011)Definition of Ready (XP2011)
Definition of Ready (XP2011)
 

Similar to TDD a piccoli passi

Similar to TDD a piccoli passi (20)

TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012TDD reloaded - JUGTAA 24 Ottobre 2012
TDD reloaded - JUGTAA 24 Ottobre 2012
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven Development
 
How to complement TDD with static analysis
How to complement TDD with static analysisHow to complement TDD with static analysis
How to complement TDD with static analysis
 
TDD Walkthrough - Encryption
TDD Walkthrough - EncryptionTDD Walkthrough - Encryption
TDD Walkthrough - Encryption
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspec
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
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
 
CPP10 - Debugging
CPP10 - DebuggingCPP10 - Debugging
CPP10 - Debugging
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud Shaon
 
Unit testing
Unit testingUnit testing
Unit testing
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
Tdd in practice
Tdd in practiceTdd in practice
Tdd in practice
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)Day1 - TDD (Lecture SS 2015)
Day1 - TDD (Lecture SS 2015)
 

More from Ferdinando Santacroce

More from Ferdinando Santacroce (10)

Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Growing Teams - Agile Venture Milano - #avmi2020
Growing Teams - Agile Venture Milano - #avmi2020Growing Teams - Agile Venture Milano - #avmi2020
Growing Teams - Agile Venture Milano - #avmi2020
 
Testare l'intestabile - Italian Agile Days 2019 #IAD19
Testare l'intestabile - Italian Agile Days 2019 #IAD19Testare l'intestabile - Italian Agile Days 2019 #IAD19
Testare l'intestabile - Italian Agile Days 2019 #IAD19
 
I'm a mediocre developer
I'm a mediocre developerI'm a mediocre developer
I'm a mediocre developer
 
Working software
Working softwareWorking software
Working software
 
I'm a mediocre developer
I'm a mediocre developerI'm a mediocre developer
I'm a mediocre developer
 
Object Calisthenics - Agile Venture Prato 2018
Object Calisthenics - Agile Venture Prato 2018Object Calisthenics - Agile Venture Prato 2018
Object Calisthenics - Agile Venture Prato 2018
 
Object Calisthenics - TDD Milano
Object Calisthenics - TDD MilanoObject Calisthenics - TDD Milano
Object Calisthenics - TDD Milano
 
Object calisthenics
Object calisthenicsObject calisthenics
Object calisthenics
 
Agile versioning with Git
Agile versioning with GitAgile versioning with Git
Agile versioning with Git
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Recently uploaded (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 

TDD a piccoli passi

Editor's Notes

  1. Sentito parlare di TDD grazie ai colleghi Esistono strumenti per testare il proprio codice Volgio imparare ad usarli! Anche perché all’inzio I test…
  2. i test li facevo così all’epoca mi occupavo di un software che interfacciava gestionale con tanti servizi e dispositivi esterni come faccio a scovare i bug prima del rilascio? prima riflessione: posso mica migliorare?
  3. Impara ad usare un framework di test Fai qualche kata Ok, fatto!
  4. Inizio test in produzione difficoltà di aggiungere test a codice esistente testare oggetti complessi come costruisco e soddisfo le dipendenze?
  5. oggetti complessi e tante dipendenze? Le soddisfo coi mock imapara framerwork di mock
  6. Impiegare 10 minuti per implementare un metodo e 3 ore per testarlo! mocki l’impossibile, ma alla fine che cosa testi che è tutto finto?! Sarà mica così che funziona? E’ ora di fare un’altra riflessione...
  7. I test li devi scrivere prima, l’hai capito o no?! Si, lo facevo, ma proprio smepre sempre «Per le cose semplici non serve TDD»
  8. Pr me TDD era così Facevo un TDD «alla buona»
  9. scopro solid principles leggo un paio di libri, leggo zio bob, Scopro 3 laws of TDD
  10. Kata
  11. il codice come una sequenza di trasformazioni, di complessità incrementale
  12. il codice come una sequenza di trasformazioni, di complessità incrementale
  13. il codice come una sequenza di trasformazioni, di complessità incrementale