Testing Pyramid and Mocking Trade-offs

#139 - A Developer's Guide to Effective Software Testing - Mauricio Aniche

Topic 4 of 13

Published Jul 3, 2023 · Clip 17:53–22:58 (5:05)

Mauricio discusses the testing pyramid as a pragmatic guide: unit tests are cheap, fast, robust, and sit at the base, while integration and end-to-end tests are done less. He also appreciates the Software Engineering at Google perspective of classifying tests by speed (fast pre-merge vs. slow separate runs) rather than unit vs. integration. On the mocking debate, he argues mocking is appropriate for things you don't control (like external web services) but databases shouldn't be mocked since real database tests can run fast today. He emphasizes writing many fast tests, and reserving integration tests for actual integration bugs rather than using them to exercise simple code paths.