adapter
A small piece of your own code that sits in front of someone else's library or service and exposes only what you need.
In more detail
Double your adapter, not the third-party library, because the library's behaviour is not yours to predict. Test the adapter against the real thing occasionally, and let every other test use a double of it.
Related terms
- dev/prod parity — Keeping development, staging and production as similar as possible in timing, people and tools.
- database — A program that stores data in an organised way and answers questions about it, such as PostgreSQL.
- seam — A place in the code where you can swap in different behaviour without editing the code itself, such as a parameter.
- test double — Any object that replaces a real dependency in a test: a stub returns canned data, a fake is a small working implementation, and a mock checks interactions.
- collaborator — Another object or service that the code under test calls to get its work done, such as a payment gateway or a clock.
Taught in
- Disposability, Dev Prod Parity And Logs — DevOps & Site Reliability Engineering
- What Test Doubles Are For — Automated Testing, TDD & Quality Engineering
- Why Over-Mocking Breeds False Positives — Automated Testing, TDD & Quality Engineering