Test Automation Framework Vocabulary
5 exercises — practise the English terms for test doubles, runner hooks, assertion matchers, the test pyramid, and CI/CD pipeline testing language.
0 / 5 completed
1 / 5
A developer is writing a unit test for an email notification service. They want to replace the real email-sending dependency with a fake that simply returns a success response without sending any actual email, and they do not need to verify how many times the method was called. Which test double should they use?
A stub returns canned responses; a mock verifies interactions; a spy records real calls; a fake is a lightweight working implementation.
The scenario explicitly states "no need to verify how many times it was called" — this rules out a mock (which sets expectations and fails tests when they're not met) and a spy (which records calls for later assertion). A fake would be a real in-memory implementation, which is heavier than needed here. A stub is the exact fit: you pre-configure it to return a success response, use it in the test to isolate the email dependency, and never assert anything about its call history.
Key vocabulary:
• Stub — returns hard-coded/pre-configured responses; no interaction verification
• Mock — pre-programmed with expectations; test fails if expectations are not met
• Spy — wraps a real object and records calls; asserted after the fact
• Fake — a simplified but working implementation (e.g. in-memory DB, fake SMTP server)
• Test double — the umbrella term for any object replacing a real dependency in a test
The scenario explicitly states "no need to verify how many times it was called" — this rules out a mock (which sets expectations and fails tests when they're not met) and a spy (which records calls for later assertion). A fake would be a real in-memory implementation, which is heavier than needed here. A stub is the exact fit: you pre-configure it to return a success response, use it in the test to isolate the email dependency, and never assert anything about its call history.
Key vocabulary:
• Stub — returns hard-coded/pre-configured responses; no interaction verification
• Mock — pre-programmed with expectations; test fails if expectations are not met
• Spy — wraps a real object and records calls; asserted after the fact
• Fake — a simplified but working implementation (e.g. in-memory DB, fake SMTP server)
• Test double — the umbrella term for any object replacing a real dependency in a test