180 likes | 303 Vues
In software testing, the concept of mocking is crucial for developing reliable and maintainable tests. Mocking allows developers to simulate the behavior of complex dependencies, enabling tests to focus on the code under scrutiny. This article explores the benefits of using fakes, stubs, and mocks, emphasizing that it is often easier to create these simulations than to interact with real objects. It advocates for approaches that encourage efficiency, repeatability, and trustworthiness in testing, aligning with the idea that a good testing strategy can empower developers and enhance productivity.
E N D
Speed (kmph) – Altitude (m/100) Distance (km)
Runkeeper design Distance (km) – time (minutes) Waypoints
Always fake it if you can! • Tie your objects to interfaces • Mock them whenever you can
Fake Talk • Fakes • Stubs • Mocks
Why fake it? • It’s easier • There is a good kind of lazy • Promotes RTFM
RTFM! • A test should be • Repeatable • Trustworthy • Fast • Maintainable