Software Engineering :: Automated Testing :: Test Double :: About :: one of the most misunderstood and misused concepts in testing
⪼ Made with 💜 by Polyglot.
Mocks are one of the most misunderstood and misused concepts in testing.
Here’s how to simplify it:
• Dummy: used only for initialization, has no behavior • Stub: simulating incoming interactions, like returning hard-coded data • Spy: record and verify outgoing interactions • Mock: enforce behaviors and verify outgoing interactions • Fake: lightweight implementation of the dependency
Each has its use case. If you’re confused about which to use when, check out my latest post.
The secret to quality testing is using the right test double for the right job.
