SlideShare a Scribd company logo
Test Driven Development
Clean Code that works!!!
Agenda
2
Intro to TDD
TDD by example
Conclusions
Intro
3
What is TDD
Developed (or rediscovered) by Kent Beck to encourage
simple design and inspire confidence.
Related to the test-first programming concepts of eXtrem
Programming
A software development process that relies on the
repetition of a very short development cicle
4
The golden rules
Never write model code
unless you have a test that
requires it
Write new code only if an
automated test has failed
Eliminate duplication
5
What's my motivation?
TDD<piè di
pagina><piè di
pagina><piè di 6
COURAGE
Clean Code that works!!!
Managing fear
“I have a problem and I
can't see the end from
the beginning”
Fear says you to be
carefull
7
TDD mantra
8
Benefits
9
Programmers who wrote more tests tended to be more productive
Programmers using TDD rarely felt the need to invoke a debugger
TDD offers validation of correctness and drives the design of a program
TDD offers the ability to take small steps
Even if more code is required, the total code implementation time could be
shorter
TDD can lead to more modularized, flexible and extensible code
Because no more code is written than necessary to pass a failing test case, tests
tend to cover every code path.
TDD by example
10
Multi Currency Money
11
Bond portfolio management system.
Company Shares Price Total
Pippo SpA 1000 25 25000
Pluto srl 400 100 40000
Total 65000
Multy currency report
Company Shar
es
Price Total
Pippo SpA 1000 25 EUR 25000 EUR
Gastone SaS 400 100 USD 40000 USD
Total 65000 EUR
Rates
From To Rate
USD EUR 2
12
Conclusions
13
TDD Best Practices I
Work only on one test at a time
14
TDD Best Practices II
Write test assertions
self-explanatory
15
TDD Best Practices III
Same structure for tests and
source code
16
TDD Best Practices IV
Keep tests small
17
TDD Best Practices V.I
integrate your code every few unit test and never
leave broken tests
18
If you are working in a team...
TDD Best Practices V.II
end every day with a broken test
19
If you are working alone...
Summary
TDD Mantra
TDD rhythm
Value Object pattern
Information Hiding principle
DRY principle
20
Bibliography and references
Kent Beck – Test-Driven Development by Example, The Addison-Wesley Signature Series
Jason Gorma – Agile Java Development: Test-Driven Development using JUnit and Eclipse
WardsWiKi - http://c2.com/cgi/wiki?TestDrivenDevelopment
WardsWiKi - http://c2.com/cgi/wiki?DontRepeatYourself
www.testdriven.com
www.junit.com
www.bigthink.it/php/test-driven-development-prima-i-test-poi-il-codice
www.agiledata.org/essays/tdd.html
21
Thank you for your attention!!!
22

More Related Content

PPTX
VT.NET 20160411: An Intro to Test Driven Development (TDD)
PPTX
Test-Driven Development (TDD)
PPT
TDD And Refactoring
PPTX
TDD - Test Driven Development
PPTX
TDD - Agile
PDF
Introduction to TDD (Test Driven development) - Ahmed Shreef
PDF
TDD Flow: The Mantra in Action
PDF
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
VT.NET 20160411: An Intro to Test Driven Development (TDD)
Test-Driven Development (TDD)
TDD And Refactoring
TDD - Test Driven Development
TDD - Agile
Introduction to TDD (Test Driven development) - Ahmed Shreef
TDD Flow: The Mantra in Action
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...

What's hot (20)

PPT
Test Driven Development
PPT
Test Driven Development
PDF
An Introduction to Test Driven Development
PDF
Pitfalls Of Tdd Adoption by Bartosz Bankowski
PPT
TDD (Test Driven Design)
PPTX
Test-Driven Development
PDF
Test Driven Development (TDD)
PPTX
Test driven development
PDF
iOS Test-Driven Development
PPTX
PHPUnit - Unit testing
PPT
Scrum and Test-driven development
PPTX
Test Driven Development (TDD) Preso 360|Flex 2010
PPTX
Agile and ATDD the perfect couple
PDF
A Not-So-Serious Introduction to Test Driven Development (TDD)
PDF
Agile Programming Systems # TDD intro
PDF
Unit testing legacy code
PDF
TDD vs. ATDD - What, Why, Which, When & Where
ZIP
Test Driven Development
PDF
Test Driven iOS Development (TDD)
PDF
TDD CrashCourse Part2: TDD
Test Driven Development
Test Driven Development
An Introduction to Test Driven Development
Pitfalls Of Tdd Adoption by Bartosz Bankowski
TDD (Test Driven Design)
Test-Driven Development
Test Driven Development (TDD)
Test driven development
iOS Test-Driven Development
PHPUnit - Unit testing
Scrum and Test-driven development
Test Driven Development (TDD) Preso 360|Flex 2010
Agile and ATDD the perfect couple
A Not-So-Serious Introduction to Test Driven Development (TDD)
Agile Programming Systems # TDD intro
Unit testing legacy code
TDD vs. ATDD - What, Why, Which, When & Where
Test Driven Development
Test Driven iOS Development (TDD)
TDD CrashCourse Part2: TDD
Ad

Viewers also liked (20)

PPT
Test driven-development
PDF
TDD - Short for Test Driven Development!
PPTX
Test-Driven Development In Action
PDF
SE- PRODUCTS
PDF
Programme brasage 2014
DOC
Protokoll Vom 30.11.09
PDF
Flipping the pimp
PPTX
Interfaces humanas con kinect
PDF
Cómo valoran la RSC y el periodismo social los Medios y los periodistas
PDF
Seguros agropecuarios y gestión integral de riesgos
 
PDF
Clients TS Consulting has worked with
PDF
Revista nuevas tecnologias
PDF
Cach hoi va tra loi ve so thich trong tieng anh
PDF
Damas - market management system for TSO
PPSX
Presentacion VI jornadas Voluntariado Cáritas Toledo
DOC
EId Al Nakib CV
PDF
Lifeloc EASYCAL Automatic Calibration Brochure for Workplace Breath Testers
PPTX
Neurología y apoptosis paola imbaquingo
PPT
Rosa rueda cárceles 1
PDF
Construyendo Aplicaciones Web con PHP + LUA + REDIS
Test driven-development
TDD - Short for Test Driven Development!
Test-Driven Development In Action
SE- PRODUCTS
Programme brasage 2014
Protokoll Vom 30.11.09
Flipping the pimp
Interfaces humanas con kinect
Cómo valoran la RSC y el periodismo social los Medios y los periodistas
Seguros agropecuarios y gestión integral de riesgos
 
Clients TS Consulting has worked with
Revista nuevas tecnologias
Cach hoi va tra loi ve so thich trong tieng anh
Damas - market management system for TSO
Presentacion VI jornadas Voluntariado Cáritas Toledo
EId Al Nakib CV
Lifeloc EASYCAL Automatic Calibration Brochure for Workplace Breath Testers
Neurología y apoptosis paola imbaquingo
Rosa rueda cárceles 1
Construyendo Aplicaciones Web con PHP + LUA + REDIS
Ad

Similar to Test Driven Development (20)

PPTX
Test driven development
PPTX
Test driven development
PPTX
Test driven development
PPTX
Test driven development
PPTX
Test driven development
PPTX
Test driven development
PPTX
Test-Driven-Development.pptx
PPT
Test Driven Development - Overview and Adoption
PPTX
Test Driven Development
ODP
xUnit and TDD: Why and How in Enterprise Software, August 2012
PPTX
TDD in Agile
PPT
Test_Driven_Development_v5.ppt
PPTX
Test-Driven Development.pptx
PDF
PPTX
Test driven development v1.0
PPTX
Test Driven Development
PPTX
Test Driven Development
PPTX
Test-driven development & Behavior-driven development basics
PPTX
TDD - Seriously, try it! (updated '22)
PPT
Test-Driven Development
Test driven development
Test driven development
Test driven development
Test driven development
Test driven development
Test driven development
Test-Driven-Development.pptx
Test Driven Development - Overview and Adoption
Test Driven Development
xUnit and TDD: Why and How in Enterprise Software, August 2012
TDD in Agile
Test_Driven_Development_v5.ppt
Test-Driven Development.pptx
Test driven development v1.0
Test Driven Development
Test Driven Development
Test-driven development & Behavior-driven development basics
TDD - Seriously, try it! (updated '22)
Test-Driven Development

More from Consulthinkspa (17)

PPTX
GDPR - Il Nuovo Regolamento Generale sulla Protezione dei Dati
PPTX
Big Data Vs. Open Data
PPTX
Data Science
PPTX
Hot trend 2017
PPTX
Pensiero Analogico e Microservizi
PDF
DevOps - Come diventare un buon DevOpper
PDF
Increasing Android app security for free - Roberto Gassirà, Roberto Piccirill...
PDF
Consulthink Overview
PDF
Scenari introduzione Application Service Governance in Azienda
PDF
Droidcon it 2015: Android Lollipop for Enterprise
PPTX
IPv6 - Breve panoramica tra mito e realtà
PPTX
BitCoin Protocol
PDF
Big data - stack tecnologico
PPTX
Quality Software Development LifeCycle
PDF
Consulthink @ GDG Meets U - L'Aquila2014 - Codelab: Android Security -Il ke...
PDF
Android Security - Key Management at GDG DevFest Rome 2013
PDF
Prevenzione degli attacchi informatici che coinvolgono dati sensibili aziendali
GDPR - Il Nuovo Regolamento Generale sulla Protezione dei Dati
Big Data Vs. Open Data
Data Science
Hot trend 2017
Pensiero Analogico e Microservizi
DevOps - Come diventare un buon DevOpper
Increasing Android app security for free - Roberto Gassirà, Roberto Piccirill...
Consulthink Overview
Scenari introduzione Application Service Governance in Azienda
Droidcon it 2015: Android Lollipop for Enterprise
IPv6 - Breve panoramica tra mito e realtà
BitCoin Protocol
Big data - stack tecnologico
Quality Software Development LifeCycle
Consulthink @ GDG Meets U - L'Aquila2014 - Codelab: Android Security -Il ke...
Android Security - Key Management at GDG DevFest Rome 2013
Prevenzione degli attacchi informatici che coinvolgono dati sensibili aziendali

Recently uploaded (20)

PDF
Yogi Goddess Pres Conference Studio Updates
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Cell Structure & Organelles in detailed.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
Yogi Goddess Pres Conference Studio Updates
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
History, Philosophy and sociology of education (1).pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Microbial diseases, their pathogenesis and prophylaxis
LDMMIA Reiki Yoga Finals Review Spring Summer
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Complications of Minimal Access Surgery at WLH
Orientation - ARALprogram of Deped to the Parents.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
01-Introduction-to-Information-Management.pdf
Final Presentation General Medicine 03-08-2024.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Paper A Mock Exam 9_ Attempt review.pdf.
Final Presentation General Medicine 03-08-2024.pptx
Cell Structure & Organelles in detailed.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf

Test Driven Development

  • 1. Test Driven Development Clean Code that works!!!
  • 2. Agenda 2 Intro to TDD TDD by example Conclusions
  • 4. What is TDD Developed (or rediscovered) by Kent Beck to encourage simple design and inspire confidence. Related to the test-first programming concepts of eXtrem Programming A software development process that relies on the repetition of a very short development cicle 4
  • 5. The golden rules Never write model code unless you have a test that requires it Write new code only if an automated test has failed Eliminate duplication 5
  • 6. What's my motivation? TDD<piè di pagina><piè di pagina><piè di 6 COURAGE Clean Code that works!!!
  • 7. Managing fear “I have a problem and I can't see the end from the beginning” Fear says you to be carefull 7
  • 9. Benefits 9 Programmers who wrote more tests tended to be more productive Programmers using TDD rarely felt the need to invoke a debugger TDD offers validation of correctness and drives the design of a program TDD offers the ability to take small steps Even if more code is required, the total code implementation time could be shorter TDD can lead to more modularized, flexible and extensible code Because no more code is written than necessary to pass a failing test case, tests tend to cover every code path.
  • 11. Multi Currency Money 11 Bond portfolio management system. Company Shares Price Total Pippo SpA 1000 25 25000 Pluto srl 400 100 40000 Total 65000 Multy currency report Company Shar es Price Total Pippo SpA 1000 25 EUR 25000 EUR Gastone SaS 400 100 USD 40000 USD Total 65000 EUR Rates From To Rate USD EUR 2
  • 12. 12
  • 14. TDD Best Practices I Work only on one test at a time 14
  • 15. TDD Best Practices II Write test assertions self-explanatory 15
  • 16. TDD Best Practices III Same structure for tests and source code 16
  • 17. TDD Best Practices IV Keep tests small 17
  • 18. TDD Best Practices V.I integrate your code every few unit test and never leave broken tests 18 If you are working in a team...
  • 19. TDD Best Practices V.II end every day with a broken test 19 If you are working alone...
  • 20. Summary TDD Mantra TDD rhythm Value Object pattern Information Hiding principle DRY principle 20
  • 21. Bibliography and references Kent Beck – Test-Driven Development by Example, The Addison-Wesley Signature Series Jason Gorma – Agile Java Development: Test-Driven Development using JUnit and Eclipse WardsWiKi - http://c2.com/cgi/wiki?TestDrivenDevelopment WardsWiKi - http://c2.com/cgi/wiki?DontRepeatYourself www.testdriven.com www.junit.com www.bigthink.it/php/test-driven-development-prima-i-test-poi-il-codice www.agiledata.org/essays/tdd.html 21
  • 22. Thank you for your attention!!! 22