[This article was first published on Jakub Sobolewski, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.You might call them all “mock”.Mock the database. Mock the API. Mock the function. The word becomes a catch-all for any test double, any object you substitute for a real dependency in a test. Lumping them together makes it harder to choose the right tool, and the wrong choice leads to brittle, misleading tests.There are five distinct types, each with a specific job. Knowing which is which is how you stop writing tests that do the wrong thing.The code under testAll five examples use a single function: process_payment. It charges a card, logs the attempt, and optionally notifies the customer.process_payment