On Toothpaste and Testing

I often call the approach of bottom-up testing toothpaste testing. You start from the bottom and slowly squeeze your way to the top. It goes hand in hand with toothpaste refactoring, which follows the same pattern and is supported by toothpaste testing.

Toothpaste refactoring provides an alternative to the legacy rescue approach of using characterization tests to drive down from the top. Both have their places. I have seen many occasions in which seemingly beneficial refactorings—such as adding dependency injection or changing signatures—percolate down through the call hierarchy only to be stopped by some strange construct. Additionally, top-down refactoring runs the risk of going long periods of time without your testing ...

Get Quality Code: Software Testing Principles, Practices, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.