SlideShare a Scribd company logo
TDD, where did it all go
wrong?
Seven years after
Who are you?
• Software Developer for more than 20 years
• Worked mainly for ISVs
• Reuters, SunGard, Misys, Huddle
• Worked for a couple of MIS departments
• DTI, Beazley
• Microsoft MVP for C#
• Interested in architecture and design
• Interested in Agile methodologies and practices
• No smart guys
• Just the guys in this room
2
3
Agenda
• The Fallacies of TDD
• Red-Green-Refactor
• Behavior not Details
• Clean Architecture
• Principles
4
2013
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
The Fallacies of TDD
1: Developers write Unit Tests
I call them “unit tests,” but they don't
match the accepted definition of unit tests very well
Kent Beck, TDD By Example
To isolate issues that may arise, each test case should be
tested independently. Substitutes such as method stubs,
mock objects, fakes, and test harnesses can be used to
assist testing a module in isolation.
https://en.wikipedia.org/wiki/Unit_testing
Need-driven Development [is a] variation on the test-driven
development process where code is written from the outside in
and all depended-on code is replaced by Mock Objects that verify
the expected indirect outputs of the code being written.
Meszaros, Gerard. xUnit Test Patterns
Our need for Inversion of Control containers, over Poor
Man’s DI is due to Need-Driven Development
When I look around now, I see a lot of people using mocks to
replace all their dependencies. My concern is that they will
begin to hit the Fragile Test issues that mocks present. Gerard
Meszaros identifies the issues we hit as two specific smells:
Overspecified Software and Behavior Sensitivity.
http://codebetter.com/iancooper/2007/12/19/mocks-and-the-dangers-of-overspecified-software/
https://twitter.com/KentBeck/status/1182714083230904320
Refactoring (noun): a change made to the internal structure
of software to make it easier to understand and cheaper to
modify without changing its observable behavior.
https://martinfowler.com/bliki/DefinitionOfRefactoring.html
If the program’s behavior is stable from an observer’s
perspective, no tests should change.
https://medium.com/@kentbeck_7670/programmer-test-principles-d01c064d7934
My personal style is I just don’t go very far down the mock
path… your test is completely coupled to the
implementation not the interface… of course you can’t
change anything without breaking the tests
Kent Beck https://www.youtube.com/watch?v=z9quxZsLcfo
Failure of a Unit Test shall implicate one (1) and only one (1)
unit. (A method, class, module, or package.)
Failure of a Programmer Test, under Test Driven
Development, implicates only the most recent edit.
https://wiki.c2.com/?ProgrammerTest
https://wiki.c2.com/?DeveloperTest
Test Driven Development produces Developer Tests. The
failure of a test case implicates only the developer's most
recent edit. This implies that developers don't need to use
Mock Objects to split all their code up into testable units.
And it implies a developer may always avoid debugging by
reverting that last edit.
https://wiki.c2.com/?UnitTest
How should the running of tests affect one another? Not at all.
Kent Beck, TDD By Example
Avoid using mocks for anything other than issues with:
• Isolated Test
• Fast Test
• Fragile Test
2: Customers write Acceptance Tests
Originally called Functional Tests because each acceptance
test tries to test the functionality of a user story.
Acceptance tests are different [is] modeled and possibly
even written by the customer. ...Hence the even-newer
name, Customer Test.
https://wiki.c2.com/?AcceptanceTest
These two problems--that customers don't participate, which
eliminates the purpose of acceptance testing, and that they
create a significant maintenance burden, means that acceptance
testing isn't worth the cost. I no longer use it or recommend it.
James Shore, http://www.jamesshore.com/Blog/The-Problems-With-Acceptance-Testing.html
Customers illustrate their descriptions with concrete
examples…programmers use these examples to guide their
work…Sometimes [programmers] use the examples directly in their
tests…More often…programmers use the examples as a guide,
writing a multitude of more focused, programmer-centric tests as
they use TDD
https://www.jamesshore.com/v2/blog/2010/alternatives-to-acceptance-testing
TDD should create tests that can be read, so that others can
understand the requirements
ATDD is perilous because it implies that TDD does not deal with the
acceptance criteria for stories
3: The trigger for a new test is a new function
The trigger for a test is a new requirement
We need to be able to add amounts in
two different currencies and convert the
result given a set of exchange rates.
Kent Beck, TDD By Example
The next test you write in TDD is just the most
obvious step that you can make towards
implementing the requirement given by a use case
or user story.
I found the shift from thinking in tests to thinking in
behaviour so profound that I started to refer to TDD as
BDD, or behaviour- driven development.
https://dannorth.net/introducing-bdd/
4: It doesn’t matter if you are test first or test last
You need a way to think about design, you need a
method for scope control
Kent Beck, TDD By Example
When we write a test, we imagine the perfect interface for
our operation. We are telling ourselves a story about how
the operation will look from the outside.
Kent Beck, TDD By Example
If you are struggling to write a test, because the
acceptance criteria for the story are not clear – TDD is
working
One of the hardest things to communicate about
test-driven development is the mental state that it
puts you in.
Martin Fowler in Kent Beck, TDD By Example
5: You want 100% test coverage of your code
If we test first, we don’t end up with speculative code.
We should not introduce new paths in refactoring, we
need a new test.
But not all of our code should be driven by TDD
Don’t drive visual output
Don’t drive a spike or other throwaway code
Don’t drive 3rd party code
Don’t drive integration
TDD is for fast binary feedback.
It works best where we can develop in short cycles.
If the feedback is not quick, consider another method to confirm
This is where we use a test double
6: TDD is sufficient
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
Fallacies Summary
1: Developers write Unit Tests
2: Customers write Acceptance Tests
3: The trigger for a new test is a new function
4: It doesn’t matter if you are test first or test last
5: You want 100% test coverage of your code
6: TDD is sufficient
Red-Green-Refactor
Red-Green-Refactor
1 Red Write a little test that doesn't work, and perhaps
doesn't even compile at first.
2.Green Make the test work quickly, committing
whatever sins necessary in the process.
3.Refactor Eliminate all of the duplication
created in merely getting the test to work.
Write a test.
Remove duplication.
Make it compile.
Run it to see that it fails.
Make it run.
Make it run. Quickly getting that bar to go to green
dominates everything else.
This shift in aesthetics is hard for some experienced
software engineers.
This is not just about accepting sin, its about
being sinful
Write sinful code!
We can commit any number of sins to get there,
because speed trumps design, just for that brief
moment.
Kent Beck, TDD by Example
Good design at good times. Make it run, make it
right.
Kent Beck, TDD by Example
The Refactoring Step is when we produce clean code.
It’s when you apply patterns [Kerievsky].
It’s when you remove duplication [Beck]
It’s when you sanitize the code smells. [Fowler]
Pattern Test Writing Refactoring
Command X
Value Object X
Null Object X
Template Method X
Pluggable Object X
Pluggable Selector X
Factory Method X X
Imposter X X
Composite X X
Collecting Parameter X X
Kent Beck, TDD By Example
You do not write new unit tests when refactoring to
clean code.
You are not introducing public classes.
It is likely if you feel the need to introduce a new public class, you
may need collaborators that fulfill a role.
Clean Architecture
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
Delivery
Mechanism
Request Model
Response
Model
Interactor
<<interface>>
Entity
Entity
Entity
Entity
Data Structure
Frameworks &
Drivers
Boundary
Interface Adapters
Use Cases
Entity Gateway
<<interface>>
60
We write tests
against use
cases
Our tests are
just another
adapter
XUnit
Framework
Request Model
Response
Model
Interactor
<<interface>>
Entity
Entity
Entity
Entity
Data Structure
Frameworks &
Drivers
Test
Interface Adapters
Use Cases
Entity Gateway
<<interface>>
In-Memory
DB
Delivery
Mechanism
62
XUnit
Framework
Request Model
Response
Model
IHandleRequests
<<interface>>
Entity
Entity
Entity
Entity
Data Structure
Frameworks &
Drivers
Test
Interface Adapters
Use Cases
Entity Gateway
<<interface>>
In-Memory
DB
Delivery
Mechanism
63
AsyncRequest
Handler
We don’t write
tests against the
adapterOur tests are
just another
adapter
We write
system tests
for acceptance
Principles
1:Respond to behaviour changes
2: Not respond to structure changes
3: Should be Fast
4: Should not be fragile
5: Cheap to write
6: Easy to read
7: Easy to change
https://medium.com/@kentbeck_7670/programmer-test-principles-d01c064d7934
Q&A

More Related Content

PDF
Intoduction to numpy
Faraz Ahmed
 
PPTX
C# File IO Operations
Prem Kumar Badri
 
PPT
Advanced Javascript
Adieu
 
PPT
Uml class diagram and packages ppt for dot net
mekhap
 
PPTX
Advance OOP concepts in Python
Sujith Kumar
 
PPT
Unit testing framework
Igor Vavrish
 
PPTX
How to choose best containers in STL (C++)
Sangharsh agarwal
 
Intoduction to numpy
Faraz Ahmed
 
C# File IO Operations
Prem Kumar Badri
 
Advanced Javascript
Adieu
 
Uml class diagram and packages ppt for dot net
mekhap
 
Advance OOP concepts in Python
Sujith Kumar
 
Unit testing framework
Igor Vavrish
 
How to choose best containers in STL (C++)
Sangharsh agarwal
 

What's hot (20)

PPT
Java: Java Applets
Tareq Hasan
 
PPTX
Component based development | what, why and how
Rakesh Kumar Jha
 
PDF
What is Python? | Edureka
Edureka!
 
PPTX
Group functions
sehrishishaq1
 
PPTX
Javascript functions
Alaref Abushaala
 
PPTX
Ch18 - Service Oriented Software Engineering
Harsh Verdhan Raj
 
PPTX
Design Pattern in Software Engineering
Manish Kumar
 
PPT
Groovy presentation
Manav Prasad
 
PPTX
Quality & Reliability in Software Engineering
SivaRamaSundar Devasubramaniam
 
PPT
CSharp.ppt
ckthesolo
 
PDF
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
PDF
Design patterns tutorials
University of Technology
 
PPTX
System Modelling
Jennifer Polack
 
PPT
Javascript arrays
Hassan Dar
 
PDF
Standard template library
Jancypriya M
 
PPTX
Java generics(Under The Hood Of The Compiler) by Harmeet singh
Harmeet Singh(Taara)
 
PPTX
Web development using javaScript, React js, Node js, HTML, CSS and SQL
Jayant Surana
 
PPT
MYSQL
Ankush Jain
 
Java: Java Applets
Tareq Hasan
 
Component based development | what, why and how
Rakesh Kumar Jha
 
What is Python? | Edureka
Edureka!
 
Group functions
sehrishishaq1
 
Javascript functions
Alaref Abushaala
 
Ch18 - Service Oriented Software Engineering
Harsh Verdhan Raj
 
Design Pattern in Software Engineering
Manish Kumar
 
Groovy presentation
Manav Prasad
 
Quality & Reliability in Software Engineering
SivaRamaSundar Devasubramaniam
 
CSharp.ppt
ckthesolo
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
WebStackAcademy
 
Design patterns tutorials
University of Technology
 
System Modelling
Jennifer Polack
 
Javascript arrays
Hassan Dar
 
Standard template library
Jancypriya M
 
Java generics(Under The Hood Of The Compiler) by Harmeet singh
Harmeet Singh(Taara)
 
Web development using javaScript, React js, Node js, HTML, CSS and SQL
Jayant Surana
 
Ad

Similar to Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after (20)

PPTX
{10.0} Test Driven Development.pptx
AmalEldhose2
 
PDF
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Abdelkrim Boujraf
 
PPT
Test Driven Development
nikhil sreeni
 
PPTX
Test Driven Development
Sergey Aganezov
 
PPTX
Test-driven development & Behavior-driven development basics
Oleksii Prohonnyi
 
PPTX
An Introduction to Developer Testing
Will Green
 
PPTX
TDD - Seriously, try it - Codemotion (May '24)
Nacho Cougil
 
PPTX
TDD - Seriously, try it! - Opensouthcode
Nacho Cougil
 
PPTX
Test driven development
Luis Goldster
 
PPTX
Test driven development
Young Alista
 
PPTX
Test driven development
Tony Nguyen
 
PPTX
Test driven development
Fraboni Ec
 
PPTX
Test driven development
James Wong
 
PPTX
Test driven development
Harry Potter
 
PPTX
TDD - Seriously, try it! (updated '22)
Nacho Cougil
 
PDF
Real developers-dont-need-unit-tests
John Ferguson Smart Limited
 
PDF
Real developers-dont-need-unit-tests
Skills Matter
 
PDF
Real developers-dont-need-unit-tests
Skills Matter
 
PDF
Effective Testing Practices in an Agile Environment
Raj Indugula
 
{10.0} Test Driven Development.pptx
AmalEldhose2
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Abdelkrim Boujraf
 
Test Driven Development
nikhil sreeni
 
Test Driven Development
Sergey Aganezov
 
Test-driven development & Behavior-driven development basics
Oleksii Prohonnyi
 
An Introduction to Developer Testing
Will Green
 
TDD - Seriously, try it - Codemotion (May '24)
Nacho Cougil
 
TDD - Seriously, try it! - Opensouthcode
Nacho Cougil
 
Test driven development
Luis Goldster
 
Test driven development
Young Alista
 
Test driven development
Tony Nguyen
 
Test driven development
Fraboni Ec
 
Test driven development
James Wong
 
Test driven development
Harry Potter
 
TDD - Seriously, try it! (updated '22)
Nacho Cougil
 
Real developers-dont-need-unit-tests
John Ferguson Smart Limited
 
Real developers-dont-need-unit-tests
Skills Matter
 
Real developers-dont-need-unit-tests
Skills Matter
 
Effective Testing Practices in an Agile Environment
Raj Indugula
 
Ad

More from Iranian Domain-Driven Design Community (10)

PDF
Principles of Advanced Software Engineering for Managing Complexity.pdf
Iranian Domain-Driven Design Community
 
PPTX
Clean architecture تاملی در
Iranian Domain-Driven Design Community
 
PPTX
کشف ناشناخته‌ها به سبک EventStorming
Iranian Domain-Driven Design Community
 
PPTX
هنر کشف گنج، تطبیق مرزها - علیرضا رحمانی خلیلی
Iranian Domain-Driven Design Community
 
PPTX
"DDD Balm on Legacy Wounds" presented at 2nd #DDDTalks event, Tehran, Iran
Iranian Domain-Driven Design Community
 
PPTX
How Event Strming can helps to find Bounded Contexts
Iranian Domain-Driven Design Community
 
PPTX
Autonomous Bounded Contexts
Iranian Domain-Driven Design Community
 
PPTX
جادوی زبان، طلسم پیچیدگی
Iranian Domain-Driven Design Community
 
Principles of Advanced Software Engineering for Managing Complexity.pdf
Iranian Domain-Driven Design Community
 
Clean architecture تاملی در
Iranian Domain-Driven Design Community
 
کشف ناشناخته‌ها به سبک EventStorming
Iranian Domain-Driven Design Community
 
هنر کشف گنج، تطبیق مرزها - علیرضا رحمانی خلیلی
Iranian Domain-Driven Design Community
 
"DDD Balm on Legacy Wounds" presented at 2nd #DDDTalks event, Tehran, Iran
Iranian Domain-Driven Design Community
 
How Event Strming can helps to find Bounded Contexts
Iranian Domain-Driven Design Community
 
Autonomous Bounded Contexts
Iranian Domain-Driven Design Community
 
جادوی زبان، طلسم پیچیدگی
Iranian Domain-Driven Design Community
 

Recently uploaded (20)

PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
PPTX
TestNG for Java Testing and Automation testing
ssuser0213cb
 
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
PDF
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PDF
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
oapresentation.pptx
mehatdhavalrajubhai
 
TestNG for Java Testing and Automation testing
ssuser0213cb
 
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Hironori Washizaki
 
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Presentation about variables and constant.pptx
safalsingh810
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 

Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after

  • 1. TDD, where did it all go wrong? Seven years after
  • 2. Who are you? • Software Developer for more than 20 years • Worked mainly for ISVs • Reuters, SunGard, Misys, Huddle • Worked for a couple of MIS departments • DTI, Beazley • Microsoft MVP for C# • Interested in architecture and design • Interested in Agile methodologies and practices • No smart guys • Just the guys in this room 2
  • 3. 3
  • 4. Agenda • The Fallacies of TDD • Red-Green-Refactor • Behavior not Details • Clean Architecture • Principles 4
  • 8. 1: Developers write Unit Tests
  • 9. I call them “unit tests,” but they don't match the accepted definition of unit tests very well Kent Beck, TDD By Example
  • 10. To isolate issues that may arise, each test case should be tested independently. Substitutes such as method stubs, mock objects, fakes, and test harnesses can be used to assist testing a module in isolation. https://en.wikipedia.org/wiki/Unit_testing
  • 11. Need-driven Development [is a] variation on the test-driven development process where code is written from the outside in and all depended-on code is replaced by Mock Objects that verify the expected indirect outputs of the code being written. Meszaros, Gerard. xUnit Test Patterns
  • 12. Our need for Inversion of Control containers, over Poor Man’s DI is due to Need-Driven Development
  • 13. When I look around now, I see a lot of people using mocks to replace all their dependencies. My concern is that they will begin to hit the Fragile Test issues that mocks present. Gerard Meszaros identifies the issues we hit as two specific smells: Overspecified Software and Behavior Sensitivity. http://codebetter.com/iancooper/2007/12/19/mocks-and-the-dangers-of-overspecified-software/
  • 15. Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior. https://martinfowler.com/bliki/DefinitionOfRefactoring.html
  • 16. If the program’s behavior is stable from an observer’s perspective, no tests should change. https://medium.com/@kentbeck_7670/programmer-test-principles-d01c064d7934
  • 17. My personal style is I just don’t go very far down the mock path… your test is completely coupled to the implementation not the interface… of course you can’t change anything without breaking the tests Kent Beck https://www.youtube.com/watch?v=z9quxZsLcfo
  • 18. Failure of a Unit Test shall implicate one (1) and only one (1) unit. (A method, class, module, or package.) Failure of a Programmer Test, under Test Driven Development, implicates only the most recent edit. https://wiki.c2.com/?ProgrammerTest https://wiki.c2.com/?DeveloperTest
  • 19. Test Driven Development produces Developer Tests. The failure of a test case implicates only the developer's most recent edit. This implies that developers don't need to use Mock Objects to split all their code up into testable units. And it implies a developer may always avoid debugging by reverting that last edit. https://wiki.c2.com/?UnitTest
  • 20. How should the running of tests affect one another? Not at all. Kent Beck, TDD By Example
  • 21. Avoid using mocks for anything other than issues with: • Isolated Test • Fast Test • Fragile Test
  • 22. 2: Customers write Acceptance Tests
  • 23. Originally called Functional Tests because each acceptance test tries to test the functionality of a user story. Acceptance tests are different [is] modeled and possibly even written by the customer. ...Hence the even-newer name, Customer Test. https://wiki.c2.com/?AcceptanceTest
  • 24. These two problems--that customers don't participate, which eliminates the purpose of acceptance testing, and that they create a significant maintenance burden, means that acceptance testing isn't worth the cost. I no longer use it or recommend it. James Shore, http://www.jamesshore.com/Blog/The-Problems-With-Acceptance-Testing.html
  • 25. Customers illustrate their descriptions with concrete examples…programmers use these examples to guide their work…Sometimes [programmers] use the examples directly in their tests…More often…programmers use the examples as a guide, writing a multitude of more focused, programmer-centric tests as they use TDD https://www.jamesshore.com/v2/blog/2010/alternatives-to-acceptance-testing
  • 26. TDD should create tests that can be read, so that others can understand the requirements
  • 27. ATDD is perilous because it implies that TDD does not deal with the acceptance criteria for stories
  • 28. 3: The trigger for a new test is a new function
  • 29. The trigger for a test is a new requirement
  • 30. We need to be able to add amounts in two different currencies and convert the result given a set of exchange rates. Kent Beck, TDD By Example
  • 31. The next test you write in TDD is just the most obvious step that you can make towards implementing the requirement given by a use case or user story.
  • 32. I found the shift from thinking in tests to thinking in behaviour so profound that I started to refer to TDD as BDD, or behaviour- driven development. https://dannorth.net/introducing-bdd/
  • 33. 4: It doesn’t matter if you are test first or test last
  • 34. You need a way to think about design, you need a method for scope control Kent Beck, TDD By Example
  • 35. When we write a test, we imagine the perfect interface for our operation. We are telling ourselves a story about how the operation will look from the outside. Kent Beck, TDD By Example
  • 36. If you are struggling to write a test, because the acceptance criteria for the story are not clear – TDD is working
  • 37. One of the hardest things to communicate about test-driven development is the mental state that it puts you in. Martin Fowler in Kent Beck, TDD By Example
  • 38. 5: You want 100% test coverage of your code
  • 39. If we test first, we don’t end up with speculative code.
  • 40. We should not introduce new paths in refactoring, we need a new test.
  • 41. But not all of our code should be driven by TDD
  • 42. Don’t drive visual output Don’t drive a spike or other throwaway code Don’t drive 3rd party code Don’t drive integration
  • 43. TDD is for fast binary feedback. It works best where we can develop in short cycles. If the feedback is not quick, consider another method to confirm This is where we use a test double
  • 44. 6: TDD is sufficient
  • 48. 1: Developers write Unit Tests 2: Customers write Acceptance Tests 3: The trigger for a new test is a new function 4: It doesn’t matter if you are test first or test last 5: You want 100% test coverage of your code 6: TDD is sufficient
  • 50. Red-Green-Refactor 1 Red Write a little test that doesn't work, and perhaps doesn't even compile at first. 2.Green Make the test work quickly, committing whatever sins necessary in the process. 3.Refactor Eliminate all of the duplication created in merely getting the test to work.
  • 51. Write a test. Remove duplication. Make it compile. Run it to see that it fails. Make it run.
  • 52. Make it run. Quickly getting that bar to go to green dominates everything else. This shift in aesthetics is hard for some experienced software engineers. This is not just about accepting sin, its about being sinful Write sinful code!
  • 53. We can commit any number of sins to get there, because speed trumps design, just for that brief moment. Kent Beck, TDD by Example
  • 54. Good design at good times. Make it run, make it right. Kent Beck, TDD by Example
  • 55. The Refactoring Step is when we produce clean code. It’s when you apply patterns [Kerievsky]. It’s when you remove duplication [Beck] It’s when you sanitize the code smells. [Fowler]
  • 56. Pattern Test Writing Refactoring Command X Value Object X Null Object X Template Method X Pluggable Object X Pluggable Selector X Factory Method X X Imposter X X Composite X X Collecting Parameter X X Kent Beck, TDD By Example
  • 57. You do not write new unit tests when refactoring to clean code. You are not introducing public classes. It is likely if you feel the need to introduce a new public class, you may need collaborators that fulfill a role.
  • 61. We write tests against use cases Our tests are just another adapter
  • 62. XUnit Framework Request Model Response Model Interactor <<interface>> Entity Entity Entity Entity Data Structure Frameworks & Drivers Test Interface Adapters Use Cases Entity Gateway <<interface>> In-Memory DB Delivery Mechanism 62
  • 63. XUnit Framework Request Model Response Model IHandleRequests <<interface>> Entity Entity Entity Entity Data Structure Frameworks & Drivers Test Interface Adapters Use Cases Entity Gateway <<interface>> In-Memory DB Delivery Mechanism 63 AsyncRequest Handler
  • 64. We don’t write tests against the adapterOur tests are just another adapter
  • 67. 1:Respond to behaviour changes 2: Not respond to structure changes 3: Should be Fast 4: Should not be fragile 5: Cheap to write 6: Easy to read 7: Easy to change https://medium.com/@kentbeck_7670/programmer-test-principles-d01c064d7934
  • 68. Q&A