Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active September 17, 2024 00:08
Show Gist options
  • Select an option

  • Save wilmoore/7ff0cf39e8bdacf898169d5a12114eb6 to your computer and use it in GitHub Desktop.

Select an option

Save wilmoore/7ff0cf39e8bdacf898169d5a12114eb6 to your computer and use it in GitHub Desktop.
Software Engineering :: Automated Testing :: Test Double :: About :: Mocks are one of the most misunderstood and misused concepts in testing

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.

image


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment