The cycle continues
All the techniques mentioned in the last section help us isolate pieces of code and break dependencies with other classes. This allows us to introduce stubs and mocks, making it easier to write more detailed characterization tests. The Extract Method refactoring is used a lot and is a great technique to isolate small sections of code.
The whole process is iterative. In a typical session, we might look at a piece of code via pdb, and then decide to extract it to a method. We might then experiment with passing different inputs to the extracted method in the interactive shell, following which we might write a few characterization tests. We would then go back to another section of the class and write more tests after mocking or ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access