What’s the difference between faking, mocking, and stubbing?

Technology CommunityCategory: TestingWhat’s the difference between faking, mocking, and stubbing?
VietMX Staff asked 3 years ago

Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production

Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what’s programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it ‘sent’, or maybe only how many messages it ‘sent’.

Mocks are what we are talking about here: objects pre-programmed with expectations which form a specification of the calls they are expected to receive.