🧪Stub (Testing)
Also known as Stub, Test Stub, Stubbing
A fake part that always gives the answer you chose, so tests stay the same.
Think of it like
Think of it like a parrot. It gives the same answer every time you ask.
Example
Lucy's app shows an umbrella when it rains. Her test uses a stub weather service that always returns rain, so the umbrella must show.
Why it matters
Real services change their answers. A stub lets you test each case on purpose, including the rare ones.
Definition
Common mistake
Key takeaways
- 1A fixed answer. Chosen ahead of time.
- 2Does not check calls. It only answers.
- 3Sets up a case. Rain, error, empty list.