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
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
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
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

What's hot

Rest assured
Rest assuredRest assured
Rest assured
Varun Deshpande
 
Tdd and bdd
Tdd and bddTdd and bdd
Tdd and bdd
MohamedSubhiBouchi
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
AMD Developer Central
 
How to Convert a Component Design into an MUI React Code
How to Convert a Component Design into an MUI React CodeHow to Convert a Component Design into an MUI React Code
How to Convert a Component Design into an MUI React Code
WrapPixel
 
Cross-project defect prediction
Cross-project defect predictionCross-project defect prediction
Cross-project defect prediction
Thomas Zimmermann
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
Ahmed Emad
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
Ahmed El-Kady
 
Unit Test Presentation
Unit Test PresentationUnit Test Presentation
Unit Test PresentationSayedur Rahman
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
Knoldus Inc.
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing AutomationAgileEngine
 
Software Engineering (Project Management )
Software Engineering (Project  Management )Software Engineering (Project  Management )
Software Engineering (Project Management )
ShudipPal
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
Enoch Joshua
 
Angular vs React vs Vue | Javascript Frameworks Comparison | Which One You Sh...
Angular vs React vs Vue | Javascript Frameworks Comparison | Which One You Sh...Angular vs React vs Vue | Javascript Frameworks Comparison | Which One You Sh...
Angular vs React vs Vue | Javascript Frameworks Comparison | Which One You Sh...
Edureka!
 
Keyword-driven Test Automation Framework
Keyword-driven Test Automation FrameworkKeyword-driven Test Automation Framework
Keyword-driven Test Automation Framework
Mikhail Subach
 
Software testing
Software testingSoftware testing
Software testing
KarnatiChandramoules
 
IT 8076 Software Testing Unit1
IT 8076 Software Testing Unit1IT 8076 Software Testing Unit1
IT 8076 Software Testing Unit1
Roselin Mary S
 
Test Cases Vs Test Scenarios
Test Cases Vs Test ScenariosTest Cases Vs Test Scenarios
Test Cases Vs Test Scenarios
Sneha Singh
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
G ABHISEK
 

What's hot (20)

Rest assured
Rest assuredRest assured
Rest assured
 
Tdd and bdd
Tdd and bddTdd and bdd
Tdd and bdd
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
How to Convert a Component Design into an MUI React Code
How to Convert a Component Design into an MUI React CodeHow to Convert a Component Design into an MUI React Code
How to Convert a Component Design into an MUI React Code
 
Cross-project defect prediction
Cross-project defect predictionCross-project defect prediction
Cross-project defect prediction
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
 
Unit Test Presentation
Unit Test PresentationUnit Test Presentation
Unit Test Presentation
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
 
Software Engineering (Project Management )
Software Engineering (Project  Management )Software Engineering (Project  Management )
Software Engineering (Project Management )
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
Angular vs React vs Vue | Javascript Frameworks Comparison | Which One You Sh...
Angular vs React vs Vue | Javascript Frameworks Comparison | Which One You Sh...Angular vs React vs Vue | Javascript Frameworks Comparison | Which One You Sh...
Angular vs React vs Vue | Javascript Frameworks Comparison | Which One You Sh...
 
Code quality
Code quality Code quality
Code quality
 
Keyword-driven Test Automation Framework
Keyword-driven Test Automation FrameworkKeyword-driven Test Automation Framework
Keyword-driven Test Automation Framework
 
Software testing
Software testingSoftware testing
Software testing
 
IT 8076 Software Testing Unit1
IT 8076 Software Testing Unit1IT 8076 Software Testing Unit1
IT 8076 Software Testing Unit1
 
Test Cases Vs Test Scenarios
Test Cases Vs Test ScenariosTest Cases Vs Test Scenarios
Test Cases Vs Test Scenarios
 
MVVM in iOS presentation
MVVM in iOS presentationMVVM in iOS presentation
MVVM in iOS presentation
 

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

Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
Michael Denomy
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
adrianmitev
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Sachithra Gayan
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012
Justin Gordon
 
Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draft
PrabudhGupta1
 
A Study: The Analysis of Test Driven Development And Design Driven Test
A Study: The Analysis of Test Driven Development And Design Driven TestA Study: The Analysis of Test Driven Development And Design Driven Test
A Study: The Analysis of Test Driven Development And Design Driven Test
Editor IJMTER
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Abdelkrim Boujraf
 
TDD in Agile
TDD in AgileTDD in Agile
TDD in Agile
Atish Narlawar
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
ikhwanhayat
 
Test driven development
Test driven developmentTest driven development
Test driven development
namkha87
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
mCloud
 
Test driven development
Test driven developmentTest driven development
Test driven development
Harry Potter
 
Test driven development
Test driven developmentTest driven development
Test driven development
Luis Goldster
 
Test driven development
Test driven developmentTest driven development
Test driven development
Tony Nguyen
 
Test driven development
Test driven developmentTest driven development
Test driven development
Young Alista
 
Test driven development
Test driven developmentTest driven development
Test driven development
James Wong
 
Test driven development
Test driven developmentTest driven development
Test driven development
Fraboni Ec
 
The Essentials Of Test Driven Development
The Essentials Of Test Driven Development The Essentials Of Test Driven Development
The Essentials Of Test Driven Development
Rock Interview
 
Loopt unit test experiences
Loopt unit test experiencesLoopt unit test experiences
Loopt unit test experiences
Heine Frifeldt
 

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

Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Test Driven Development - Overview and Adoption
Test Driven Development - Overview and AdoptionTest Driven Development - Overview and Adoption
Test Driven Development - Overview and Adoption
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012
 
Tdd and-design-draft
Tdd and-design-draftTdd and-design-draft
Tdd and-design-draft
 
A Study: The Analysis of Test Driven Development And Design Driven Test
A Study: The Analysis of Test Driven Development And Design Driven TestA Study: The Analysis of Test Driven Development And Design Driven Test
A Study: The Analysis of Test Driven Development And Design Driven Test
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
 
TDD in Agile
TDD in AgileTDD in Agile
TDD in Agile
 
Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
The Essentials Of Test Driven Development
The Essentials Of Test Driven Development The Essentials Of Test Driven Development
The Essentials Of Test Driven Development
 
Loopt unit test experiences
Loopt unit test experiencesLoopt unit test experiences
Loopt unit test experiences
 

More from Iranian Domain-Driven Design Community

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

More from Iranian Domain-Driven Design Community (10)

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

Recently uploaded

OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
varshanayak241
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
NaapbooksPrivateLimi
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 

Recently uploaded (20)

OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Strategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptxStrategies for Successful Data Migration Tools.pptx
Strategies for Successful Data Migration Tools.pptx
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Visitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.appVisitor Management System in India- Vizman.app
Visitor Management System in India- Vizman.app
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 

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
  • 6.
  • 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
  • 45.
  • 46.
  • 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.
  • 59.
  • 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