SlideShare a Scribd company logo
1 of 43
Ahmed Misbah - September 2022
TDD Anti-patterns
2022 edition
TDD Anti-patterns
Agenda
• About the speaker

• What is TDD?

• The anti-patterns

• References
TDD Anti-patterns
Agenda
➡ About the speaker

• What is TDD?

• The anti-patterns

• References
About the speaker
Role and previous talks
• Chief Software Engineer and Architect

• Speaker at:

‣ Delta Technopreneurs

‣ DevOpsDays Cairo

‣ AMECSE

‣ Orange DevTest Days

‣ GDG

‣ JDC
About the speaker
Topics of interest
• DevOps

• Agile and Lean

• Cloud-Native Apps and beyond

• Software Architecture

• Java

• FOSS

• Arti
fi
cial Intelligence and ML
About the speaker
Experience
• 9 years at Orange Innovation Egypt

• Delivered two award winning innovative
solutions

• Worked at two startups

• Helped many others!

• Winner of Dell Hacktrick 2022 UI/UX track

• MSc. degree in ML and many other
professional certi
fi
cations
Nile University
J;.lll ~l:J.. Qtertifirate
(3/'~
This is to certify that
Ahmed Mahmoud Amir Misbah
••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
Has successfully completed the program of study
and fulfilled the requirements for
BigData & Data Science Diploma
for the period from October 2015 to July 2016
...f:.!.l...~'!!~~!.tf....El..#.!(!.~.1..
INF Program Director
~~.__QI II
C.a.::::a..;r:q;;; AU J M
IW fl ,
: ~t '-M4'
October 2016 ·
····························••-
•··············
Date
TDD Anti-patterns
Agenda
• About the speaker

➡ What is TDD?

• The anti-patterns

• References
Martin Fowler
“Test-Driven Development (TDD) is a technique for building software that
guides software development by writing tests. It was developed by Kent
Beck in the late 1990's as part of Extreme Programming. In essence you
follow three simple steps repeatedly:


• Write a test for the next bit of functionality you want to add.


• Write the functional code until the test passes.


• Refactor both new and old code to make it well structured.”
TDD Anti-patterns
Agenda
• About the speaker

• What is TDD?

➡ The anti-patterns

• References
TDD Anti-patterns
7 anti-patterns
1. No test list

2. No refactoring

3. No pair/mob programming

4. No particular school

5. No integration

6. No mutation testing

7. Practice + technology before theory
(1) No test list
Kent Beck
“Test-Driven Development By Example”, Chapter 25 - Test Driven Development
Patterns
“What should you test? Before you begin, write a list of all the
tests you know you will have to write. The first part of our
approach to dealing with programming stress is never to take
a step forward unless we know where our foot is going to
land. When we sit down to a programming session, what is it
we intend to accomplish?”
No test list
The true Red-Green-Refactor
• Invented by James Shore in 2005 (link)

• Steps:

1. Think: Figure out what test will best move
your code towards completion. (Take as
much time as you need. This is the hardest
step for beginners.)

2. Red

3. Green

4. Refactor

5. Repeat
“The Coding Dojo Handbook”, Section 3
No test list
How to write a test list?
• Pair/mob with testers

• Use test design techniques
Sample test list by Kent Beck
(2) No refactoring
Martin Fowler
“The most common way that I hear to screw up TDD is
neglecting the third step. Refactoring the code to keep it clean
is a key part of the process, otherwise you just end up with a
messy aggregation of code fragments. (At least these will
have tests, so it's a less painful result than most failures of
design.)”
Refactoring
What do we do in the refactor phase?
• It’s when you remove duplication - Kent Beck

• It’s when you sanitize the code smells - Martin
Fowler

• It’s when you apply patterns - Joshua Kerievsky
“TDD, Where Did it All Go Wrong” video
Refactoring
It’s all about design
• “There is no design phase in TDD. Using TDD, design is inverted and distributed”

• “TDD completely inverts the accepted ordering of ‘design-code-test'”

• “TDD just puts the design after the test and the code. Refactoring is pure design.”

“Test-Driven Development” eLearning Album - Industrial Logic
Code
Design Test Refactor
Code
Test
Design/
Refactor
(3) No pair / mob programming
No pair / mob programming
Issues with working solo in TDD
Learning curve (technologies, recommended
practices, etc.)

Knowledge sharing (technologies, recommended
practices, business, test list, etc.)

Collective ownership (of production code and tests)
(4) No particular school
No particular school
Di
ff
erent Architectures
“Domain-speci
fi
c Semantic Web-based Information Systems - Any Progress?” paper
No particular school
The schools of TDD
• Classicist (aka. Chicago or Detroit school of TDD):

‣ Inside-out

‣ Tests behavior

‣ No mocks

• Mockist (aka. London school of TDD)

‣ Outside-in

‣ Tests structure?

‣ Uses mocks
No particular school
Understand the schools
• A beginners explanation of the Chicago & London approaches

• London vs. Chicago

• Chicago TDD vs London TDD – Which one is should you use?

• London vs. Chicago by Robert (Bob) Martin and Sandro Mancuso
(5) No integration
No integration
Microtesting
• Invented by Mike (GeePaw) Hill in 2011 (link)

• The Four-Beat Cycle:

1. RED

2. GREEN

3. REFACTOR

4. INTEGRATE: We commit our changes,
including the new micro-test(s), to the
source vault.
(6) No mutation testing
Alex Bunardzic
“Two things surprised me a lot recently:


1. Number of experienced TDDers who told me they fail to see
value in Mutation testing


2. Number of experienced TDDers who told me they fail to see
value in TCR”
No mutation testing
Why Mutation Tests?
• Traditional test coverage (i.e., line,
statement, branch, etc.) measures only
which code is executed by your tests. It
does not check that your tests are able
to detect faults in the executed code. It is
therefore only able to identify code that is
not tested

• As it can detect whether each statement is
meaningfully tested, mutation testing is
the gold standard against which all other
types of coverage are measured
Source link
(7) Practice + technology before
theory
Ahmed Galal - Mobile UX session - 2012
“Experience = Knowledge (i.e., Theory) + Practice”
Practice + technology before theory
Experience, Theory and Practice
• Experience is often used interchangeably with practice.

• However, true experience is gained by both learning knowledge and theory
and applying it (i.e., practice)
W. Edwards Deming - “The New Economics for Industry, Government, Education” book
“Experience by itself teaches nothing... Without theory,
experience has no meaning. Without theory, one has no
questions to ask. Hence, without theory, there is no
learning.”
Practice + technology before theory
Knowledge then practice + technology
• Beginners start with courses that teach technologies without diving deep into
the theory and recommended practices

• Beginners should read:

- The three laws of TDD - “Clean Code” by Robert (Bob) C. Martin

- F.I.R.S.T properties - “Clean Code” by Robert (Bob) C. Martin

- Test Desiderata - Kent Beck

- TDD Manifesto
Thank you!
References
References
Book a free call to arrange a workshop
• Introduction to TDD

• Advanced topics in TDD

• TDD and refactoring workshop
Scan to book a free call

More Related Content

What's hot

What's hot (20)

Intro to DevOps
Intro to DevOpsIntro to DevOps
Intro to DevOps
 
DevOps on AWS: DevOps Day San Francisco
DevOps on AWS: DevOps Day San FranciscoDevOps on AWS: DevOps Day San Francisco
DevOps on AWS: DevOps Day San Francisco
 
intro to DevOps
intro to DevOpsintro to DevOps
intro to DevOps
 
Hexagonal Architecture.pdf
Hexagonal Architecture.pdfHexagonal Architecture.pdf
Hexagonal Architecture.pdf
 
CI/CD on Google Cloud Platform
CI/CD on Google Cloud PlatformCI/CD on Google Cloud Platform
CI/CD on Google Cloud Platform
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
 
Anti-Patterns
Anti-PatternsAnti-Patterns
Anti-Patterns
 
Testing in Agile Projects
Testing in Agile ProjectsTesting in Agile Projects
Testing in Agile Projects
 
SRE From Scratch
SRE From ScratchSRE From Scratch
SRE From Scratch
 
Lean Software Development
Lean Software DevelopmentLean Software Development
Lean Software Development
 
ING Container Hosting Platform - 3 years onward_with Kube_for distribution.pdf
ING Container Hosting Platform - 3 years onward_with Kube_for distribution.pdfING Container Hosting Platform - 3 years onward_with Kube_for distribution.pdf
ING Container Hosting Platform - 3 years onward_with Kube_for distribution.pdf
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICD
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
Agile testing
Agile testingAgile testing
Agile testing
 
Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?
 
Dev ops != Dev+Ops
Dev ops != Dev+OpsDev ops != Dev+Ops
Dev ops != Dev+Ops
 
Agile Testing and Test Automation
Agile Testing and Test AutomationAgile Testing and Test Automation
Agile Testing and Test Automation
 

Similar to TDD Anti-patterns (2022 edition)

Similar to TDD Anti-patterns (2022 edition) (20)

TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012TDD - Christchurch APN May 2012
TDD - Christchurch APN May 2012
 
TDD in Agile
TDD in AgileTDD in Agile
TDD in Agile
 
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
Joe Cisar - Everything I Know About TDD - Agile Midwest 2019
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)TDD - Seriously, try it! (updated '22)
TDD - Seriously, try it! (updated '22)
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
TDD - Seriously, try it! - Trójmiasto Java User Group (17th May '23)
 
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
TDD - Seriously, try it! - Trjjmiasto JUG (17th May '23)
 
Intro to TDD
Intro to TDDIntro to TDD
Intro to TDD
 
TDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech WeekTDD - Seriously, try it! - Bucarest Tech Week
TDD - Seriously, try it! - Bucarest Tech Week
 
It's XP, Stupid
It's XP, StupidIt's XP, Stupid
It's XP, Stupid
 
TDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - OpensouthcodeTDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - Opensouthcode
 
Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018Mastering BDD - Eran Kinsbruner Workshop Quest 2018
Mastering BDD - Eran Kinsbruner Workshop Quest 2018
 
Test-Driven Development in the Corporate Workplace
Test-Driven Development in the Corporate WorkplaceTest-Driven Development in the Corporate Workplace
Test-Driven Development in the Corporate Workplace
 
Clean code - Getting your R&D on board
Clean code - Getting your R&D on boardClean code - Getting your R&D on board
Clean code - Getting your R&D on board
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Understanding Why Testing is Importaint
Understanding Why Testing is ImportaintUnderstanding Why Testing is Importaint
Understanding Why Testing is Importaint
 
TDD - Seriously, try it - Codemotion (May '24)
TDD - Seriously, try it - Codemotion (May '24)TDD - Seriously, try it - Codemotion (May '24)
TDD - Seriously, try it - Codemotion (May '24)
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
Transferring Software Testing Tools to Practice
Transferring Software Testing Tools to PracticeTransferring Software Testing Tools to Practice
Transferring Software Testing Tools to Practice
 

More from Ahmed Misbah

More from Ahmed Misbah (20)

6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)
 
Migrating to Microservices Patterns and Technologies (edition 2023)
 Migrating to Microservices Patterns and Technologies (edition 2023) Migrating to Microservices Patterns and Technologies (edition 2023)
Migrating to Microservices Patterns and Technologies (edition 2023)
 
Practical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdfPractical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdf
 
Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)
 
DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)
 
Implementing FaaS on Kubernetes using Kubeless
Implementing FaaS on Kubernetes using KubelessImplementing FaaS on Kubernetes using Kubeless
Implementing FaaS on Kubernetes using Kubeless
 
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
 
Getting Started with DevOps
Getting Started with DevOpsGetting Started with DevOps
Getting Started with DevOps
 
DevOps for absolute beginners
DevOps for absolute beginnersDevOps for absolute beginners
DevOps for absolute beginners
 
Microservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioMicroservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and Istio
 
Cucumber jvm best practices v3
Cucumber jvm best practices v3Cucumber jvm best practices v3
Cucumber jvm best practices v3
 
Welcome to the Professional World
Welcome to the Professional WorldWelcome to the Professional World
Welcome to the Professional World
 
More topics on Java
More topics on JavaMore topics on Java
More topics on Java
 
Career Paths for Software Professionals
Career Paths for Software ProfessionalsCareer Paths for Software Professionals
Career Paths for Software Professionals
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story Writing
 
AndGen+
AndGen+AndGen+
AndGen+
 
DDT Testing Library for Android
DDT Testing Library for AndroidDDT Testing Library for Android
DDT Testing Library for Android
 
Big Data for QAs
Big Data for QAsBig Data for QAs
Big Data for QAs
 
Software Architecture
Software ArchitectureSoftware Architecture
Software Architecture
 
Software Design
Software DesignSoftware Design
Software Design
 

Recently uploaded

Recently uploaded (20)

Test Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfTest Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdf
 
architecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdfarchitecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdf
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
 
From Knowledge Graphs via Lego Bricks to scientific conversations.pptx
From Knowledge Graphs via Lego Bricks to scientific conversations.pptxFrom Knowledge Graphs via Lego Bricks to scientific conversations.pptx
From Knowledge Graphs via Lego Bricks to scientific conversations.pptx
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
GraphSummit Milan & Stockholm - Neo4j: The Art of the Possible with Graph
GraphSummit Milan & Stockholm - Neo4j: The Art of the Possible with GraphGraphSummit Milan & Stockholm - Neo4j: The Art of the Possible with Graph
GraphSummit Milan & Stockholm - Neo4j: The Art of the Possible with Graph
 
Novo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNovo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMs
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 

TDD Anti-patterns (2022 edition)

  • 1. Ahmed Misbah - September 2022 TDD Anti-patterns 2022 edition
  • 2. TDD Anti-patterns Agenda • About the speaker • What is TDD? • The anti-patterns • References
  • 3. TDD Anti-patterns Agenda ➡ About the speaker • What is TDD? • The anti-patterns • References
  • 4. About the speaker Role and previous talks • Chief Software Engineer and Architect • Speaker at: ‣ Delta Technopreneurs ‣ DevOpsDays Cairo ‣ AMECSE ‣ Orange DevTest Days ‣ GDG ‣ JDC
  • 5. About the speaker Topics of interest • DevOps • Agile and Lean • Cloud-Native Apps and beyond • Software Architecture • Java • FOSS • Arti fi cial Intelligence and ML
  • 6. About the speaker Experience • 9 years at Orange Innovation Egypt • Delivered two award winning innovative solutions • Worked at two startups • Helped many others! • Winner of Dell Hacktrick 2022 UI/UX track • MSc. degree in ML and many other professional certi fi cations Nile University J;.lll ~l:J.. Qtertifirate (3/'~ This is to certify that Ahmed Mahmoud Amir Misbah •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• Has successfully completed the program of study and fulfilled the requirements for BigData & Data Science Diploma for the period from October 2015 to July 2016 ...f:.!.l...~'!!~~!.tf....El..#.!(!.~.1.. INF Program Director ~~.__QI II C.a.::::a..;r:q;;; AU J M IW fl , : ~t '-M4' October 2016 · ····························••- •·············· Date
  • 7. TDD Anti-patterns Agenda • About the speaker ➡ What is TDD? • The anti-patterns • References
  • 8. Martin Fowler “Test-Driven Development (TDD) is a technique for building software that guides software development by writing tests. It was developed by Kent Beck in the late 1990's as part of Extreme Programming. In essence you follow three simple steps repeatedly: • Write a test for the next bit of functionality you want to add. • Write the functional code until the test passes. • Refactor both new and old code to make it well structured.”
  • 9. TDD Anti-patterns Agenda • About the speaker • What is TDD? ➡ The anti-patterns • References
  • 10. TDD Anti-patterns 7 anti-patterns 1. No test list 2. No refactoring 3. No pair/mob programming 4. No particular school 5. No integration 6. No mutation testing 7. Practice + technology before theory
  • 11. (1) No test list
  • 12. Kent Beck “Test-Driven Development By Example”, Chapter 25 - Test Driven Development Patterns “What should you test? Before you begin, write a list of all the tests you know you will have to write. The first part of our approach to dealing with programming stress is never to take a step forward unless we know where our foot is going to land. When we sit down to a programming session, what is it we intend to accomplish?”
  • 13.
  • 14. No test list The true Red-Green-Refactor • Invented by James Shore in 2005 (link) • Steps: 1. Think: Figure out what test will best move your code towards completion. (Take as much time as you need. This is the hardest step for beginners.) 2. Red 3. Green 4. Refactor 5. Repeat
  • 15. “The Coding Dojo Handbook”, Section 3
  • 16. No test list How to write a test list? • Pair/mob with testers • Use test design techniques Sample test list by Kent Beck
  • 18. Martin Fowler “The most common way that I hear to screw up TDD is neglecting the third step. Refactoring the code to keep it clean is a key part of the process, otherwise you just end up with a messy aggregation of code fragments. (At least these will have tests, so it's a less painful result than most failures of design.)”
  • 19. Refactoring What do we do in the refactor phase? • It’s when you remove duplication - Kent Beck • It’s when you sanitize the code smells - Martin Fowler • It’s when you apply patterns - Joshua Kerievsky “TDD, Where Did it All Go Wrong” video
  • 20. Refactoring It’s all about design • “There is no design phase in TDD. Using TDD, design is inverted and distributed” • “TDD completely inverts the accepted ordering of ‘design-code-test'” • “TDD just puts the design after the test and the code. Refactoring is pure design.” “Test-Driven Development” eLearning Album - Industrial Logic Code Design Test Refactor Code Test Design/ Refactor
  • 21. (3) No pair / mob programming
  • 22. No pair / mob programming Issues with working solo in TDD Learning curve (technologies, recommended practices, etc.) Knowledge sharing (technologies, recommended practices, business, test list, etc.) Collective ownership (of production code and tests)
  • 24. No particular school Di ff erent Architectures “Domain-speci fi c Semantic Web-based Information Systems - Any Progress?” paper
  • 25. No particular school The schools of TDD • Classicist (aka. Chicago or Detroit school of TDD): ‣ Inside-out ‣ Tests behavior ‣ No mocks • Mockist (aka. London school of TDD) ‣ Outside-in ‣ Tests structure? ‣ Uses mocks
  • 26. No particular school Understand the schools • A beginners explanation of the Chicago & London approaches • London vs. Chicago • Chicago TDD vs London TDD – Which one is should you use? • London vs. Chicago by Robert (Bob) Martin and Sandro Mancuso
  • 28.
  • 29. No integration Microtesting • Invented by Mike (GeePaw) Hill in 2011 (link) • The Four-Beat Cycle: 1. RED 2. GREEN 3. REFACTOR 4. INTEGRATE: We commit our changes, including the new micro-test(s), to the source vault.
  • 30. (6) No mutation testing
  • 31. Alex Bunardzic “Two things surprised me a lot recently: 1. Number of experienced TDDers who told me they fail to see value in Mutation testing 2. Number of experienced TDDers who told me they fail to see value in TCR”
  • 32. No mutation testing Why Mutation Tests? • Traditional test coverage (i.e., line, statement, branch, etc.) measures only which code is executed by your tests. It does not check that your tests are able to detect faults in the executed code. It is therefore only able to identify code that is not tested • As it can detect whether each statement is meaningfully tested, mutation testing is the gold standard against which all other types of coverage are measured Source link
  • 33.
  • 34. (7) Practice + technology before theory
  • 35. Ahmed Galal - Mobile UX session - 2012 “Experience = Knowledge (i.e., Theory) + Practice”
  • 36. Practice + technology before theory Experience, Theory and Practice • Experience is often used interchangeably with practice. • However, true experience is gained by both learning knowledge and theory and applying it (i.e., practice)
  • 37. W. Edwards Deming - “The New Economics for Industry, Government, Education” book “Experience by itself teaches nothing... Without theory, experience has no meaning. Without theory, one has no questions to ask. Hence, without theory, there is no learning.”
  • 38. Practice + technology before theory Knowledge then practice + technology • Beginners start with courses that teach technologies without diving deep into the theory and recommended practices • Beginners should read: - The three laws of TDD - “Clean Code” by Robert (Bob) C. Martin - F.I.R.S.T properties - “Clean Code” by Robert (Bob) C. Martin - Test Desiderata - Kent Beck - TDD Manifesto
  • 42.
  • 43. Book a free call to arrange a workshop • Introduction to TDD • Advanced topics in TDD • TDD and refactoring workshop Scan to book a free call