SlideShare a Scribd company logo
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

PDF
TDD python ne-april-2014
PPTX
HA with RelStorage and Postgres
PPTX
TDD er død. Lenge leve TDD!
PDF
Test Driven Development in Python
PDF
Manage Selenium Grid with Terraform by Omkar Khatavkar (https://www.linkedin....
PDF
Best practices for unit testing RxJava
PDF
Unit testing legacy code
PDF
Andro sec rl-prototype-finalproject
TDD python ne-april-2014
HA with RelStorage and Postgres
TDD er død. Lenge leve TDD!
Test Driven Development in Python
Manage Selenium Grid with Terraform by Omkar Khatavkar (https://www.linkedin....
Best practices for unit testing RxJava
Unit testing legacy code
Andro sec rl-prototype-finalproject

What's hot (8)

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

Viewers also liked (6)

PPTX
Gestione del Product Backlog: un decluttering efficace
PDF
Product Owner - Scopriamo questo sconosciuto!
PDF
Accidenti! Non è command and control! ovvero Stili di leadership in un conte...
PPTX
System integration through queues
PPTX
Agile Data Science
PDF
Definition of Ready (XP2011)
Gestione del Product Backlog: un decluttering efficace
Product Owner - Scopriamo questo sconosciuto!
Accidenti! Non è command and control! ovvero Stili di leadership in un conte...
System integration through queues
Agile Data Science
Definition of Ready (XP2011)
Ad

Similar to TDD a piccoli passi (20)

PDF
TDD reloaded - JUGTAA 24 Ottobre 2012
PDF
iOS Test-Driven Development
PDF
How to complement TDD with static analysis
PDF
TDD Walkthrough - Encryption
PDF
Test Driven Development
PDF
It's all about behaviour, also in php - phpspec
PPTX
Test Driven Development on Android (Kotlin Kenya)
PPTX
Tdd is not about testing (C++ version)
PPTX
Test-Driven Development In Action
PDF
TDD and Simple Design Workshop - Session 1 - March 2019
PPT
CPP10 - Debugging
PDF
Tdd is not about testing
PPTX
Tdd is not about testing (OOP)
PDF
Getting started with Test Driven Development
PPTX
Getting started with Test Driven Development - Ferdous Mahmud Shaon
PPTX
Unit testing
PDF
TDD Flow: The Mantra in Action
PDF
Tdd in practice
PDF
Test Driven Development
PDF
Day1 - TDD (Lecture SS 2015)
TDD reloaded - JUGTAA 24 Ottobre 2012
iOS Test-Driven Development
How to complement TDD with static analysis
TDD Walkthrough - Encryption
Test Driven Development
It's all about behaviour, also in php - phpspec
Test Driven Development on Android (Kotlin Kenya)
Tdd is not about testing (C++ version)
Test-Driven Development In Action
TDD and Simple Design Workshop - Session 1 - March 2019
CPP10 - Debugging
Tdd is not about testing
Tdd is not about testing (OOP)
Getting started with Test Driven Development
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Unit testing
TDD Flow: The Mantra in Action
Tdd in practice
Test Driven Development
Day1 - TDD (Lecture SS 2015)

More from Ferdinando Santacroce (10)

PPTX
Continuous Delivery
PDF
Growing Teams - Agile Venture Milano - #avmi2020
PPTX
Testare l'intestabile - Italian Agile Days 2019 #IAD19
PDF
I'm a mediocre developer
PPTX
Working software
PPTX
I'm a mediocre developer
PDF
Object Calisthenics - Agile Venture Prato 2018
PPTX
Object Calisthenics - TDD Milano
PDF
Object calisthenics
PPTX
Agile versioning with Git
Continuous Delivery
Growing Teams - Agile Venture Milano - #avmi2020
Testare l'intestabile - Italian Agile Days 2019 #IAD19
I'm a mediocre developer
Working software
I'm a mediocre developer
Object Calisthenics - Agile Venture Prato 2018
Object Calisthenics - TDD Milano
Object calisthenics
Agile versioning with Git

Recently uploaded (20)

PPTX
ai tools demonstartion for schools and inter college
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
top salesforce developer skills in 2025.pdf
PDF
medical staffing services at VALiNTRY
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
System and Network Administraation Chapter 3
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
System and Network Administration Chapter 2
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Digital Strategies for Manufacturing Companies
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
PTS Company Brochure 2025 (1).pdf.......
ai tools demonstartion for schools and inter college
Upgrade and Innovation Strategies for SAP ERP Customers
top salesforce developer skills in 2025.pdf
medical staffing services at VALiNTRY
Navsoft: AI-Powered Business Solutions & Custom Software Development
System and Network Administraation Chapter 3
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Operating system designcfffgfgggggggvggggggggg
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Which alternative to Crystal Reports is best for small or large businesses.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Migrate SBCGlobal Email to Yahoo Easily
Wondershare Filmora 15 Crack With Activation Key [2025
System and Network Administration Chapter 2
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
2025 Textile ERP Trends: SAP, Odoo & Oracle
Digital Strategies for Manufacturing Companies
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PTS Company Brochure 2025 (1).pdf.......

TDD a piccoli passi

Editor's Notes

  • #2: Sentito parlare di TDD grazie ai colleghi Esistono strumenti per testare il proprio codice Volgio imparare ad usarli! Anche perché all’inzio I test…
  • #3: 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?
  • #4: Impara ad usare un framework di test Fai qualche kata Ok, fatto!
  • #5: Inizio test in produzione difficoltà di aggiungere test a codice esistente testare oggetti complessi come costruisco e soddisfo le dipendenze?
  • #6: oggetti complessi e tante dipendenze? Le soddisfo coi mock imapara framerwork di mock
  • #7: 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...
  • #8: 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»
  • #9: Pr me TDD era così Facevo un TDD «alla buona»
  • #10: scopro solid principles leggo un paio di libri, leggo zio bob, Scopro 3 laws of TDD
  • #13: Kata
  • #14: il codice come una sequenza di trasformazioni, di complessità incrementale
  • #15: il codice come una sequenza di trasformazioni, di complessità incrementale
  • #16: il codice come una sequenza di trasformazioni, di complessità incrementale