Testing Without Mocks: A Pattern Language (2023)

Automated tests are crucial for programmers to save time and ensure code quality. While traditional automated tests can be wasteful and slow, using mocks and spies can improve test reliability and speed. However, these methods can complicate refactoring and lead to poor-quality tests. A new pattern language described in this article offers a fourth option that combines the speed and reliability of unit tests with the power of broad tests without the need for architectural changes. The language utilizes Narrow Tests, State-Based Tests, and Overlapping Sociable Tests to provide readable, fast, and maintainable tests. The approach also introduces Nullables, an innovative infrastructure technique, to eliminate the need for mock tests. Tradeoffs include changes to production code and hand-written stub code for infrastructure components. Overall, this pattern language offers a unique and effective testing solution for developers looking to streamline their testing process.

https://www.jamesshore.com/v2/projects/nullables/testing-without-mocks

To top