The Implicit Contract of Mocks
What is a mock “Mock” is one of those words that means subtly different things to different people, so, to be specific, in this post I am using the following definition: a mock is a test double that stands in for a real component by satisfying its API and enforces assertions on how that API gets called during a test. The mocks that mockery generates would be Go examples.
Every mock writes a contract Tests codify promises about functionality into executable logic that can verify that those promises are kept, effectively making them contracts with built-in enforcement.