SlideShare a Scribd company logo
The Ten Commandments of TDD Hernán Wilkinson Agile 2011
What is TDD?
This is NOT TDD, this is how you do it! So… what is the ESENCE of TDD
TDD is not about testing only It is more than that…
TDD is about doing  incremental   problem solving  guided by  concrete examples We are use to incremental development (cycles/iteration), but not incremental design/programming
TDD brings testing to development cycle Analisys Design Program. Testing
TDD brings testing to development cycle Analisys Design Program. Testing
TDD brings testing to development cycle Tests are explicit, not implicit anymore Tests run automatically, not because the a person test Tests bring requirements to live!
TDD SINCERIZA programmers about testing
A programmer that is not a good tester is not a good programmer Good Programmer = Good Tester =
TDD is a cultural change… a big one
The Commandments Management ones Technical one About testing About design (Sadly, they are more than ten…)
The Management Commandments
You shall not expect your developers do TDD because it is God, I mean Good  
You shall not expect your developers do TDD because it is God, I mean Good   It is a Cultural Change! Cultural changes do not happen by themselves  As manager, you have to provide the environment for the change and support it …  and yes sometimes you have to be tuff, it is part of being a leader It is great start doing Pair Programming!
You shall provide time to do TDD
You shall provide time to do TDD YES!! Doing TDD TAKES TIME!!!  and more at the beginning… It is a cultural change! BUT… the time you “invest” doing TDD gets pay in the mid-term Finding a bug running the tests during a regression has no price!… for the rest you have mastercard
You shall not send mixed messages stopping TDD when time looks not enough
You shall not send mixed messages stopping TDD when time looks not enough The problem is the PLAN… it is a PLAN for God sake! If you HAVE TO do it, provide a reasonable explanation, talk to your team!
You shall not expect no errors at all
You shall not expect no errors at all Testing is not a “formal verification technique” You can not say anything about what it is not tested… that is why it is important to write the test first DO NOT STOP DOING TDD because you got some errors on production Use Mutation Testing/Coverage to test your tests!!
You shall not expect one hundred percent coverage
You shall not expect one hundred percent coverage Sometimes it is too costly to automatize certain tests Coverage is not a good measure of testing quality 100% coverage is impossible when just starting to do TDD
You shall not remove the QA team due to TDD
You shall not remove the QA team due to TDD Because TDD is not about testing only! Because TDD does not test UI, user experience, performance, scalability, etc, etc TDD helps QA to concentrate on the real and important issues
You shall wait for your team to be “test infected”
You shall wait for your team to be “test infected” Experience is IMPORTANT. Wait your team to become expert, it will not happen in a week Do not mix senior programmers with junior programmers, but semi-senior programmers with both (Pragmatic thinking and learning)
The Technical Commandments
You shall write the test first
You shall write the test first Is about incremental design and programming Is not about providing a generic implementation with one case It is not only about not doing what is not necessary If you don’t do it, you will lie to yourself and forget to write some tests If you don’t do it, you are just testing IT IS THE MOST DIFICULT PART
You shall assert in your tests
You shall assert in your tests Test without assertion is not a test, it is just a mere observation If you don’t have an assertion, re-think the whole test or remove it
You shall not write many tests and then try to run them
You shall not write many tests and then try to run them Use a notepad to write the description of the tests that came to your mind Wrong design decisions (which is common when not knowing the whole picture) will affect all the tests you wrote You have to start feeling comfortable with the “uncertainty”… it is about incremental design/programming
You shall not believe that TDD is about unit testing only  (with classical definition of unit testing)
You shall not believe that TDD is about unit testing only  TDD is not only about testing a method or a class The more important tests are those that verify a functionality of the system Unit Test = Run fast! (less than 100 milliseconds)
You shall not name your tests after the HOW but after the WHAT
You shall not name your tests after the HOW but after the WHAT Wrong name: testAccountBalance Too generic, it is not a concrete example Good name: testGivenAnAccountWithoutTransactionsWhenAskedForItsBalanceThenItShouldReturnCero It is a concrete example Test names are LONG! and they should be
You shall verify one case per test
You shall verify one case per test To keep tests simple  If a test fails the you know by the test name what it is wrong It is difficult to name a test that verifies more than one case    smell
You shall not test twice the same
You shall not test twice the same To simplify test maintenance To keep consistency
You shall keep your tests clean, they are another system
You shall keep your tests clean, they are another system The tests are another system using yours! Test maintenance can get costly if you don’t keep them clean
You shall not start testing interfaces, you shall start testing the business model
You shall not start testing interfaces, you shall start testing the business model Because you have to start with the simplest test possible Because you want immediate feedback Because is the business model what is important regardless any interface (UI, rest, webservices, etc)
You shall not TDD using relational databases
You shall not TDD using relational databases Relational databases are SLOW (from a testing point of view) Relational databases make your development harder Relational databases misguide your design Relational databases are a solution to a computable problem: persistence Test but not TDD using relational database
You shall not test using external systems
You shall not test using external systems A Relational Database is an external system! External systems make your test slow External systems avoid your test to be in “control of everything” External systems create an unnecessary coupling with your tests Simulate external systems
You shall not mock your wife!
You shall not mock your wife! There are certain things you should not simulate! Do not simulate your business objects Only simulate what is out of your system’s reach If scenarios are difficult to create, create scenarios factories! Object collaborate, they don’t live alone by themselves
You shall understand that TDD does not imply good design
You shall understand that TDD does not imply good design Good designs are made by good designers TDD implies less couple designs but not good ones TDD does not imply not to think! TDD does not imply not to use good design techniques or rules
You shall not worry about performance at the beginning
You shall not worry about performance at the beginning You shall not worry about performance, persistence, scalability, etc. (the computational problems) You shall worry about modeling the business first!
You shall love testing as much as programming
You shall love testing as much as programming Because as programmers, we always test We do it implicitly We do it in our heads Testing is part of development GOOD PROGRAMMER = GOOD TESTER
And now the joke…
The ten commandments I am TDD your Development Technique; you shall not have strange techniques before me. You shall not take the name of TDD, your Development Technique, in vain. Remember to keep holy all days to TDD Honor your tests and your programs. You shall not kill QA
The ten commandments You shall not commit adultery forgetting to write the test first You SHALL steal other test ideas You shall not bear false witness against TDD if you have not try it. You SHALL covet your neighbor's tests. You shall not covet your neighbor's lack of testing.
We teach this and other important design aspects in our courses Advance Design with OO : Nov 14 th TDD : Oct 25 th , Nov 22 nd Check them out at: http://www.10pines.com/content/cursosdisponibles
Questions?
Muchas gracias! [email_address] www.10Pines.com twitter: @10Pines Argentina Tel.:  +54 (11) 4780-2460 Paraguay 523, 7N Buenos Aires

More Related Content

PPT
Los diez mandamientos de TDD
ODP
@LinkingNote annotation in YATSPEC
ODP
Assorted TDD tips
PPTX
Exceptions: Why, When, How and Where!
PPTX
Intro to TDD
PDF
NI week 2018 - Bringing down the barrier - A pragmatic view of software design
PPTX
Unit Test Lab - Why Write Unit Tests?
PDF
Four Stages of Automated Testing by Bradley Temple
Los diez mandamientos de TDD
@LinkingNote annotation in YATSPEC
Assorted TDD tips
Exceptions: Why, When, How and Where!
Intro to TDD
NI week 2018 - Bringing down the barrier - A pragmatic view of software design
Unit Test Lab - Why Write Unit Tests?
Four Stages of Automated Testing by Bradley Temple

What's hot (20)

PDF
Demise of test scripts rise of test ideas
PPT
Reliable tests with selenium web driver
PPTX
Development without Testers: Myth or Real Option? (ConfeT&QA conference)
PDF
Graham Thomas - Software Testing Secrets We Dare Not Tell - EuroSTAR 2013
PPT
Exploratory Testing Explained
PPTX
A Mockery of a persentation
PDF
Open source tools - Test Management Summit - 2009
PPT
Introduction to Test Driven Development
PDF
Misconceptions Of Unit Testing
PPTX
TDD & Refactoring
PPTX
Go/Ruby/Java: What's next?
PPTX
Exploratory testing workshop
PDF
Amanda Cinnamon - Treat Your Code Like the Valuable Software It Is
PPTX
Unit testing JS = SQLSat 324
ODP
Reversed Tests Pyramid - Agile Prague 2014
PDF
TestIstanbul May 2013 Keynote Experiences With Exploratory Testing
DOCX
Defining Test Competence
PPTX
Small Hyper-Productive Teams (IT Brunch)
PPTX
Test Driven Development: More Development Than Ever
PDF
David Hayman - Say What? Testing a Voice Avtivated System - EuroSTAR 2010
Demise of test scripts rise of test ideas
Reliable tests with selenium web driver
Development without Testers: Myth or Real Option? (ConfeT&QA conference)
Graham Thomas - Software Testing Secrets We Dare Not Tell - EuroSTAR 2013
Exploratory Testing Explained
A Mockery of a persentation
Open source tools - Test Management Summit - 2009
Introduction to Test Driven Development
Misconceptions Of Unit Testing
TDD & Refactoring
Go/Ruby/Java: What's next?
Exploratory testing workshop
Amanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Unit testing JS = SQLSat 324
Reversed Tests Pyramid - Agile Prague 2014
TestIstanbul May 2013 Keynote Experiences With Exploratory Testing
Defining Test Competence
Small Hyper-Productive Teams (IT Brunch)
Test Driven Development: More Development Than Ever
David Hayman - Say What? Testing a Voice Avtivated System - EuroSTAR 2010
Ad

Viewers also liked (20)

PPTX
FizzBuzz Guided Kata
PPT
Refactoring a Company - 2nd Presentation
PPTX
Tdd con Angular y jasmine
PPT
Cómo Java afecta nuestros Diseños
PPT
Tdd on the rocks
PPT
Encadenamiento de refactorings para generar cambios Agiles de Diseño
PPT
Objects: The Misunderstood Paradigm
PPT
Confianza+Participación+Transparencia= Refactorizando la empresa
PPT
Arithmetic with measures on dynamically typed object oriented languages
PPT
Como hacer tdd y no morir en el intento
PPT
Programming Language Technical debt and their influence in Thinking and Desgin
PPT
A new object oriented model of the gregorian calendar
PDF
Growing an open participative horizontal and based on trust company
PPT
Augmenting Smalltalk Syntax
PPTX
Obejct Oriented SCM - OOSCM
PDF
Facilitadores asombrosos: logrando mejores conversaciones e interacciones
PPT
Metaprogramacion
PPT
Técnicas y herramientas para que la computadora haga más y el programador m...
PDF
Como escribir buenos tests al hacer TDD
PPT
Desarrollando sistemas con metodologías y técnicas agiles
FizzBuzz Guided Kata
Refactoring a Company - 2nd Presentation
Tdd con Angular y jasmine
Cómo Java afecta nuestros Diseños
Tdd on the rocks
Encadenamiento de refactorings para generar cambios Agiles de Diseño
Objects: The Misunderstood Paradigm
Confianza+Participación+Transparencia= Refactorizando la empresa
Arithmetic with measures on dynamically typed object oriented languages
Como hacer tdd y no morir en el intento
Programming Language Technical debt and their influence in Thinking and Desgin
A new object oriented model of the gregorian calendar
Growing an open participative horizontal and based on trust company
Augmenting Smalltalk Syntax
Obejct Oriented SCM - OOSCM
Facilitadores asombrosos: logrando mejores conversaciones e interacciones
Metaprogramacion
Técnicas y herramientas para que la computadora haga más y el programador m...
Como escribir buenos tests al hacer TDD
Desarrollando sistemas con metodologías y técnicas agiles
Ad

Similar to The ten commandments of TDD (20)

PPTX
TDD Best Practices
PPTX
A Brief Introduction to Test-Driven Development
PPTX
{10.0} Test Driven Development.pptx
ODP
Effective TDD - Less is more
PPT
Test-Driven Development
PPTX
TDD - Seriously, try it - Codemotion (May '24)
PPT
TDD - Christchurch APN May 2012
PPTX
Test-Driven Development
PPTX
TDD with Visual Studio 2010
PDF
Real developers-dont-need-unit-tests
PDF
Real developers-dont-need-unit-tests
PDF
Real developers-dont-need-unit-tests
PPT
Automated Unit Testing and TDD
PDF
TDD and Simple Design Workshop - Session 1 - March 2019
PDF
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
PDF
iOS Test-Driven Development
PDF
Tdd practices
PDF
Test Driven Development (TDD)
PPTX
Best pratice
TDD Best Practices
A Brief Introduction to Test-Driven Development
{10.0} Test Driven Development.pptx
Effective TDD - Less is more
Test-Driven Development
TDD - Seriously, try it - Codemotion (May '24)
TDD - Christchurch APN May 2012
Test-Driven Development
TDD with Visual Studio 2010
Real developers-dont-need-unit-tests
Real developers-dont-need-unit-tests
Real developers-dont-need-unit-tests
Automated Unit Testing and TDD
TDD and Simple Design Workshop - Session 1 - March 2019
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
iOS Test-Driven Development
Tdd practices
Test Driven Development (TDD)
Best pratice

More from Hernan Wilkinson (15)

PDF
Hacia una síntesis de diseño a partir de entender qué es modelar con software
PDF
Live Typing - California Smalltalkers
PDF
Buenos Aires vs. (London vs. Chicago) Agiles 2020
PPTX
LiveTyping - Anotación automática de tipos para lenguajes dinámicos
PPTX
LiveTyping: Update and What is next
PPTX
Cuis smalltalk past present and future
PPTX
Live Typing - Automatic Type Annotation that improves the Programming eXperie...
PPTX
El Desarrollo de Software como debería Ser - PyConAr 2018
PPTX
Lessons Learned Implementing Refactorings
PPTX
Dynamic Type Information
PPTX
El Desarrollo de Software como debería Ser - Nerdear.la 2018
PDF
El Desarrollo de Software como debería Ser
PPTX
CuisUniversity
PPTX
Oop is not Dead
PPT
Programming Languages and their influence in Thinking
Hacia una síntesis de diseño a partir de entender qué es modelar con software
Live Typing - California Smalltalkers
Buenos Aires vs. (London vs. Chicago) Agiles 2020
LiveTyping - Anotación automática de tipos para lenguajes dinámicos
LiveTyping: Update and What is next
Cuis smalltalk past present and future
Live Typing - Automatic Type Annotation that improves the Programming eXperie...
El Desarrollo de Software como debería Ser - PyConAr 2018
Lessons Learned Implementing Refactorings
Dynamic Type Information
El Desarrollo de Software como debería Ser - Nerdear.la 2018
El Desarrollo de Software como debería Ser
CuisUniversity
Oop is not Dead
Programming Languages and their influence in Thinking

Recently uploaded (20)

PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Hybrid model detection and classification of lung cancer
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
August Patch Tuesday
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Mushroom cultivation and it's methods.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
TLE Review Electricity (Electricity).pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Encapsulation theory and applications.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Web App vs Mobile App What Should You Build First.pdf
Assigned Numbers - 2025 - Bluetooth® Document
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Encapsulation_ Review paper, used for researhc scholars
Hybrid model detection and classification of lung cancer
1 - Historical Antecedents, Social Consideration.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Hindi spoken digit analysis for native and non-native speakers
August Patch Tuesday
WOOl fibre morphology and structure.pdf for textiles
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Chapter 5: Probability Theory and Statistics
Mushroom cultivation and it's methods.pdf
A novel scalable deep ensemble learning framework for big data classification...
TLE Review Electricity (Electricity).pptx
DP Operators-handbook-extract for the Mautical Institute
Encapsulation theory and applications.pdf
OMC Textile Division Presentation 2021.pptx
Tartificialntelligence_presentation.pptx
Web App vs Mobile App What Should You Build First.pdf

The ten commandments of TDD

  • 1. The Ten Commandments of TDD Hernán Wilkinson Agile 2011
  • 3. This is NOT TDD, this is how you do it! So… what is the ESENCE of TDD
  • 4. TDD is not about testing only It is more than that…
  • 5. TDD is about doing incremental problem solving guided by concrete examples We are use to incremental development (cycles/iteration), but not incremental design/programming
  • 6. TDD brings testing to development cycle Analisys Design Program. Testing
  • 7. TDD brings testing to development cycle Analisys Design Program. Testing
  • 8. TDD brings testing to development cycle Tests are explicit, not implicit anymore Tests run automatically, not because the a person test Tests bring requirements to live!
  • 10. A programmer that is not a good tester is not a good programmer Good Programmer = Good Tester =
  • 11. TDD is a cultural change… a big one
  • 12. The Commandments Management ones Technical one About testing About design (Sadly, they are more than ten…)
  • 14. You shall not expect your developers do TDD because it is God, I mean Good 
  • 15. You shall not expect your developers do TDD because it is God, I mean Good  It is a Cultural Change! Cultural changes do not happen by themselves As manager, you have to provide the environment for the change and support it … and yes sometimes you have to be tuff, it is part of being a leader It is great start doing Pair Programming!
  • 16. You shall provide time to do TDD
  • 17. You shall provide time to do TDD YES!! Doing TDD TAKES TIME!!! and more at the beginning… It is a cultural change! BUT… the time you “invest” doing TDD gets pay in the mid-term Finding a bug running the tests during a regression has no price!… for the rest you have mastercard
  • 18. You shall not send mixed messages stopping TDD when time looks not enough
  • 19. You shall not send mixed messages stopping TDD when time looks not enough The problem is the PLAN… it is a PLAN for God sake! If you HAVE TO do it, provide a reasonable explanation, talk to your team!
  • 20. You shall not expect no errors at all
  • 21. You shall not expect no errors at all Testing is not a “formal verification technique” You can not say anything about what it is not tested… that is why it is important to write the test first DO NOT STOP DOING TDD because you got some errors on production Use Mutation Testing/Coverage to test your tests!!
  • 22. You shall not expect one hundred percent coverage
  • 23. You shall not expect one hundred percent coverage Sometimes it is too costly to automatize certain tests Coverage is not a good measure of testing quality 100% coverage is impossible when just starting to do TDD
  • 24. You shall not remove the QA team due to TDD
  • 25. You shall not remove the QA team due to TDD Because TDD is not about testing only! Because TDD does not test UI, user experience, performance, scalability, etc, etc TDD helps QA to concentrate on the real and important issues
  • 26. You shall wait for your team to be “test infected”
  • 27. You shall wait for your team to be “test infected” Experience is IMPORTANT. Wait your team to become expert, it will not happen in a week Do not mix senior programmers with junior programmers, but semi-senior programmers with both (Pragmatic thinking and learning)
  • 29. You shall write the test first
  • 30. You shall write the test first Is about incremental design and programming Is not about providing a generic implementation with one case It is not only about not doing what is not necessary If you don’t do it, you will lie to yourself and forget to write some tests If you don’t do it, you are just testing IT IS THE MOST DIFICULT PART
  • 31. You shall assert in your tests
  • 32. You shall assert in your tests Test without assertion is not a test, it is just a mere observation If you don’t have an assertion, re-think the whole test or remove it
  • 33. You shall not write many tests and then try to run them
  • 34. You shall not write many tests and then try to run them Use a notepad to write the description of the tests that came to your mind Wrong design decisions (which is common when not knowing the whole picture) will affect all the tests you wrote You have to start feeling comfortable with the “uncertainty”… it is about incremental design/programming
  • 35. You shall not believe that TDD is about unit testing only (with classical definition of unit testing)
  • 36. You shall not believe that TDD is about unit testing only TDD is not only about testing a method or a class The more important tests are those that verify a functionality of the system Unit Test = Run fast! (less than 100 milliseconds)
  • 37. You shall not name your tests after the HOW but after the WHAT
  • 38. You shall not name your tests after the HOW but after the WHAT Wrong name: testAccountBalance Too generic, it is not a concrete example Good name: testGivenAnAccountWithoutTransactionsWhenAskedForItsBalanceThenItShouldReturnCero It is a concrete example Test names are LONG! and they should be
  • 39. You shall verify one case per test
  • 40. You shall verify one case per test To keep tests simple If a test fails the you know by the test name what it is wrong It is difficult to name a test that verifies more than one case  smell
  • 41. You shall not test twice the same
  • 42. You shall not test twice the same To simplify test maintenance To keep consistency
  • 43. You shall keep your tests clean, they are another system
  • 44. You shall keep your tests clean, they are another system The tests are another system using yours! Test maintenance can get costly if you don’t keep them clean
  • 45. You shall not start testing interfaces, you shall start testing the business model
  • 46. You shall not start testing interfaces, you shall start testing the business model Because you have to start with the simplest test possible Because you want immediate feedback Because is the business model what is important regardless any interface (UI, rest, webservices, etc)
  • 47. You shall not TDD using relational databases
  • 48. You shall not TDD using relational databases Relational databases are SLOW (from a testing point of view) Relational databases make your development harder Relational databases misguide your design Relational databases are a solution to a computable problem: persistence Test but not TDD using relational database
  • 49. You shall not test using external systems
  • 50. You shall not test using external systems A Relational Database is an external system! External systems make your test slow External systems avoid your test to be in “control of everything” External systems create an unnecessary coupling with your tests Simulate external systems
  • 51. You shall not mock your wife!
  • 52. You shall not mock your wife! There are certain things you should not simulate! Do not simulate your business objects Only simulate what is out of your system’s reach If scenarios are difficult to create, create scenarios factories! Object collaborate, they don’t live alone by themselves
  • 53. You shall understand that TDD does not imply good design
  • 54. You shall understand that TDD does not imply good design Good designs are made by good designers TDD implies less couple designs but not good ones TDD does not imply not to think! TDD does not imply not to use good design techniques or rules
  • 55. You shall not worry about performance at the beginning
  • 56. You shall not worry about performance at the beginning You shall not worry about performance, persistence, scalability, etc. (the computational problems) You shall worry about modeling the business first!
  • 57. You shall love testing as much as programming
  • 58. You shall love testing as much as programming Because as programmers, we always test We do it implicitly We do it in our heads Testing is part of development GOOD PROGRAMMER = GOOD TESTER
  • 59. And now the joke…
  • 60. The ten commandments I am TDD your Development Technique; you shall not have strange techniques before me. You shall not take the name of TDD, your Development Technique, in vain. Remember to keep holy all days to TDD Honor your tests and your programs. You shall not kill QA
  • 61. The ten commandments You shall not commit adultery forgetting to write the test first You SHALL steal other test ideas You shall not bear false witness against TDD if you have not try it. You SHALL covet your neighbor's tests. You shall not covet your neighbor's lack of testing.
  • 62. We teach this and other important design aspects in our courses Advance Design with OO : Nov 14 th TDD : Oct 25 th , Nov 22 nd Check them out at: http://www.10pines.com/content/cursosdisponibles
  • 64. Muchas gracias! [email_address] www.10Pines.com twitter: @10Pines Argentina Tel.: +54 (11) 4780-2460 Paraguay 523, 7N Buenos Aires