Testability Forces Modularity
๐ณ Evergreen ยท
Hard-to-test code is a design smell: if a class is hard to test, it is doing too much. Too many input combinations, too many side effects, too many conflated concerns. The cure is extraction. Writing unit tests exerts pressure toward smaller, focused modules because the test demands a unit small enough to exercise in isolation.
Connections
- ๐ณCoverage Metrics Are Misleading
- ๐ณLaw of Demeter and Testing
- ๐ณMinimize Public Surface for Testability
- ๐ณMocks vs. Stubs: When to Use Which
- ๐ณReduce Cyclomatic Complexity
- ๐ณTestability Forces Dependency Injection
- ๐ณTests as a Refactoring Safety Net
- ๐ณTests as Executable Documentation
- ๐ณTests as First Customer
- ๐ณTests Prune the Debugging Search Space
- ๐ชถThe merits of unit tests โ Part 3