Synchronize through Injection

Synchronizing through a common lock works well as long as the common lock exists and is accessible. But what do you do when the lock is not available, or the locks that are available are in the wrong places? You create your own!

Chapter 12 looked at the various ways you can use injection points as seams. Whether through dependency injection frameworks, callbacks, registries, or logging and monitoring frameworks, the ability to inject a test double allows you to also inject synchronization.

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.