← Quiz: Unit Testing and TDD: all 10 questions
Quiz: Unit Testing and TDD · Question 5 of 10
What is the difference between a stub and a mock?
What is the difference between a stub and a mock?
- A.There is no difference
- B.A stub is used only in Java
- C.A mock returns fixed values; a stub records calls
- D.A stub returns fixed answers; a mock also records how it was called so the test can check it
Answer & explanation
Correct answer: A stub returns fixed answers; a mock also records how it was called so the test can check it
Mocks let you verify interactions, such as "send was called once".
Can you get the rest right without peeking?
Take the timed Quiz: Unit Testing and TDD quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →