Terminology Disclaimer
These terms are loosely defined and used interchangeably.
Most of the time, mock is common for all types.
Stub
- method stub
- Shortcut implementation of a method
- Typically returns hard-coded data
- Mimic external function calls and possible results
- Test error states as well as expected states
Fake
- fake object
- Mimic a real object
- Satisfy type checker
- Contain/Return default data
- Simple implementations
Mock
- test spy
- Mimic a real object
- Track all operations
- Verify that our code calls other code
- See side effects of our code beyond return values