An in-memory UserRepository that stores users in a dict and behaves like the real one is called a…
Options
- Mock
- Stub
- Fake (Correct option)
- Spy
Answer
Fake
Why
These are all 'test doubles', stand-ins for real dependencies:
- Fake: a simple but WORKING implementation (in-memory repository, fake email sender that stores messages in a list).
- Stub: returns fixed answers ('always return this user').
- Mock: pre-programmed and later checked: 'was send() called once with these arguments?'.
- Spy: wraps a real object and records how it was called.
Remember
Fake = working lightweight version of the real thing.