SlideShare a Scribd company logo
Guidelines and heuristics that will help you reach the Plateau of
Productivity
My 25-ish “laws” of Test Driven Development
Dennis Doomen
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
About Me
Hands-on architect in the .NET space with 26 years of experience on
an everlasting quest for knowledge to build the right software the right
way at the right time
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
My Laws of Test Driven Development (2023)
The Adoption Cycle for Test Driven Development
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Design for Testability
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Design class
responsibilities
Write first test
Generate stubs
Fail for the right
reason
Implement
real deal
Ensure test
succeeds
Identify alternative
scenarios
Repeat twice
Refactor
Start designing
responsibilities before
you write your first test
Then use the tests to drive the design
further
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Organize code by functionalities / capabilities
Use the Dependency
Inversion Principle to
decouple boundaries
Order Processing
IStoreOrders<T>
+ Query<T>();
+ Add<T>();
+ Delete<T>();
NHibernate
Repository
Order Processing
IStoreOrders
+ GetIncompleteOrders(minValue);
+ StoreOrder();
+ CompleteOrder();
OrderRepository
VS
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Apply DRY within those boundaries
Duplicated
Service 1
Duplicated
Service 1
Duplicated
Service 2
Duplicated
Service 2
Duplicated
Service 1
Centralized
Service 3
Extension
Methods
Extension
Methods
Extension
Methods
Extension
Methods
Helpers Helpers Helpers Helpers
Use the right scope
Dennis Doomen | @ddoomen | The Continuous Improver
Service Service
Service Service
Service
Centralized
Service
Align your test scope with those “boundaries”
But sometimes,
testing smaller is
fine too
Application
Functional Slice
Service
Critical Internal
Component
Internal
Component
Test things designed to
reusable separately…
…but test
implementation details
as part of a bigger scope
Treat adjacent folders as
separate boundaries
Test the real surface area
It’s fine to include
the database
Clarify the arrange,
act and assert
But use a different
style if that helps
Don’t bother defining
what “unit” vs
“integration” is
Test guidelines
Dennis Doomen | @ddoomen | The Continuous Improver
Write your tests like you
write your production
code
Allow your tests to be
used as documentation
It’s fine to inject concrete
classes inside boundaries
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Use mocking
between
boundaries but
avoid using them
internally
Service Service
Service Service
Service
Centralized
Service
Can use mocking
Can use
mocking
Can use mocking
Can use
mocking
Avoid
mocking
Avoid
mocking
Avoid
mocking
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Don’t return mocks from mocks
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Hide things that
are not important
for that specific
test
Ensure it fails or
succeeds for the right
reason
Prefer inline literal
strings and numbers
over constants
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Don’t use production code in
assertions
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Only assert what’s
relevant for that specific
test case
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
Keep out of the
debugger hell
Naming and organization
#avivasolutions
Postfix with Specs to
emphasize tests are
specifications
Group test by API or
purpose using nested
classes
Use short fact-based names.
Q&A
(and win a 1-year license for the JetBrains Suite)
…ping me at @ddoomen
…email me at dennis.doomen@avivasolutions.nl

More Related Content

PPTX
Vertical Slicing Architectures
PPT
Domain Driven Design Demonstrated
PPTX
The Art of Clean code
PDF
DDD Tactical Design with Clean Architecture - Ivan Paulovich
PDF
Clean pragmatic architecture @ devflix
PDF
Software Craftsmanship @Code Camp Festival 2022.pdf
PPTX
Clean Pragmatic Architecture - Avoiding a Monolith
PDF
Clean Lambdas & Streams in Java8
Vertical Slicing Architectures
Domain Driven Design Demonstrated
The Art of Clean code
DDD Tactical Design with Clean Architecture - Ivan Paulovich
Clean pragmatic architecture @ devflix
Software Craftsmanship @Code Camp Festival 2022.pdf
Clean Pragmatic Architecture - Avoiding a Monolith
Clean Lambdas & Streams in Java8

What's hot (20)

PDF
Clean architecture - Protecting the Domain
PPTX
Intro to Azure DevOps
PDF
Adopting Domain-Driven Design in your organization
PPTX
Dapr: distributed application runtime
PPTX
Azure DevOps
PPTX
Functional Patterns with Java8 @Bucharest Java User Group
PPTX
Domain Driven Design(DDD) Presentation
PDF
The Art of Unit Testing - Towards a Testable Design
PPTX
DDD In Agile
PPSX
Domain Driven Design
PDF
Intro to react native
PPTX
Continuous integration using atlassian bamboo
PDF
Clean architecture
PDF
GitOps is IaC done right
PDF
Don't Be Mocked by your Mocks - Best Practices using Mocks
PPTX
Jenkins CI
PPTX
DevOps Tutorial For Beginners | DevOps Tutorial | DevOps Tools | DevOps Train...
PPTX
The tests are trying to tell you something@VoxxedBucharest.pptx
PPTX
Boas práticas técnica para um código limpo (Clean Code)
PPTX
Domain Driven Design 101
Clean architecture - Protecting the Domain
Intro to Azure DevOps
Adopting Domain-Driven Design in your organization
Dapr: distributed application runtime
Azure DevOps
Functional Patterns with Java8 @Bucharest Java User Group
Domain Driven Design(DDD) Presentation
The Art of Unit Testing - Towards a Testable Design
DDD In Agile
Domain Driven Design
Intro to react native
Continuous integration using atlassian bamboo
Clean architecture
GitOps is IaC done right
Don't Be Mocked by your Mocks - Best Practices using Mocks
Jenkins CI
DevOps Tutorial For Beginners | DevOps Tutorial | DevOps Tools | DevOps Train...
The tests are trying to tell you something@VoxxedBucharest.pptx
Boas práticas técnica para um código limpo (Clean Code)
Domain Driven Design 101
Ad

Similar to My Laws of Test Driven Development (2023) (20)

PPTX
Tools and practices to help you deal with legacy code
PPTX
What you can learn from an open-source project with 250 million downloads
PPTX
A lab around the principles and practices for writing maintainable code (2019)
PPTX
How To Practice TDD Without Shooting Yourself In The Foot
PDF
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
PPTX
How to Practice TDD Without Shooting Yourself in the Foot
PDF
Test Driven Development
PDF
The Evolution of Development Testing
PPTX
10 Principles of Apex Testing
PPTX
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
PPTX
Overcoming the Obstacles, Pitfalls, and Dangers of Unit Testing
PPTX
From Gatekeeper to Partner by Kelsey Shannahan
PDF
Test Automation using UiPath Test Suite - Developer Circle Part-1.pdf
PPTX
How to practice TDD without shooting yourself in the foot
PDF
10 Principles of Apex Testing
PPTX
Microsoft DevOps Solution - DevOps
PPTX
DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers
PDF
25 SAP Testing Secrets
PPTX
Principles and patterns for test driven development
PPTX
TDD Best Practices
Tools and practices to help you deal with legacy code
What you can learn from an open-source project with 250 million downloads
A lab around the principles and practices for writing maintainable code (2019)
How To Practice TDD Without Shooting Yourself In The Foot
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
How to Practice TDD Without Shooting Yourself in the Foot
Test Driven Development
The Evolution of Development Testing
10 Principles of Apex Testing
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Overcoming the Obstacles, Pitfalls, and Dangers of Unit Testing
From Gatekeeper to Partner by Kelsey Shannahan
Test Automation using UiPath Test Suite - Developer Circle Part-1.pdf
How to practice TDD without shooting yourself in the foot
10 Principles of Apex Testing
Microsoft DevOps Solution - DevOps
DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers
25 SAP Testing Secrets
Principles and patterns for test driven development
TDD Best Practices
Ad

More from Dennis Doomen (20)

PDF
15 Years of Insights from a TDD Practitioner (NDC Oslo)
PPTX
Using Boundary-Driven Development to beat code complexity
PPTX
Getting a grip on your code dependencies (2023-10)
PPTX
Getting a grip on your code dependencies
PPTX
Design patterns for Event Sourcing in .NET
PPTX
Automate Infrastructure with Pulumi and C#
PPTX
What is the right unit in unit testing (UpdateConf 2022)
PPTX
Slow Event Sourcing (re)projections - Just make them faster!
PPTX
50 things software teams should not do.pptx
PPTX
What is the right "unit" in unit testing and why it is not a class?
PPTX
A lab around the principles and practices for writing maintainable code
PPTX
Decomposing the Monolith using modern-day .NET and a touch of microservices
PPTX
Event Sourcing from the Trenches (DDD Europe 2020)
PPTX
Practical introduction to DDD, CQRS and Event Sourcing
PPTX
How to practice TDD without shooting yourself in the foot
PPTX
Decomposing the Monolith (Riga Dev Days 2019)
PPTX
Lessons learned from two decades of professional software development
PPTX
The Good, The Bad and The Ugly of Event Sourcing
PPTX
Event Sourcing from the Trenches (with examples from .NET)
PPTX
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
15 Years of Insights from a TDD Practitioner (NDC Oslo)
Using Boundary-Driven Development to beat code complexity
Getting a grip on your code dependencies (2023-10)
Getting a grip on your code dependencies
Design patterns for Event Sourcing in .NET
Automate Infrastructure with Pulumi and C#
What is the right unit in unit testing (UpdateConf 2022)
Slow Event Sourcing (re)projections - Just make them faster!
50 things software teams should not do.pptx
What is the right "unit" in unit testing and why it is not a class?
A lab around the principles and practices for writing maintainable code
Decomposing the Monolith using modern-day .NET and a touch of microservices
Event Sourcing from the Trenches (DDD Europe 2020)
Practical introduction to DDD, CQRS and Event Sourcing
How to practice TDD without shooting yourself in the foot
Decomposing the Monolith (Riga Dev Days 2019)
Lessons learned from two decades of professional software development
The Good, The Bad and The Ugly of Event Sourcing
Event Sourcing from the Trenches (with examples from .NET)
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Spectroscopy.pptx food analysis technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Review of recent advances in non-invasive hemoglobin estimation
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Big Data Technologies - Introduction.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Spectral efficient network and resource selection model in 5G networks
Machine learning based COVID-19 study performance prediction
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Per capita expenditure prediction using model stacking based on satellite ima...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectroscopy.pptx food analysis technology
20250228 LYD VKU AI Blended-Learning.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation

My Laws of Test Driven Development (2023)