About 15 years ago, I got inspired by a series of posts on Test Driven Development written by the Jeremy D. Miller. Now, with many years of great and not-so-great experiences practicing Test Driven Development, I thought it is the time to capture my own “laws”. The term "law" is obviously an exaggeration and "principles or heuristics" cover my intend much better. Either way, I want to talk about the scope of testing, using the observable behavior, naming conventions, state-based vs interaction-based testing, the impact of DRY, patterns to build useful test objects and some of the libraries and tools I use. In short, everything I try to follow every day I write, review or maintain code.
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
My Laws of Test Driven Development (2023)
1. 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
2. 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
3.
4. The Adoption Cycle for Test Driven Development
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
6. 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
7. Then use the tests to drive the design
further
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
9. 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
10. 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
11. Use the right scope
Dennis Doomen | @ddoomen | The Continuous Improver
25. It’s fine to inject concrete
classes inside boundaries
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions
26. 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
27. Don’t return mocks from mocks
@ddoomen | Principal Consultant | The Continuous Improver | Aviva Solutions