A fake clock always says 9 in the morning. What kind of stand-in is it?
- A mock, because it checks calls
- A stub, because it returns a canned answer
- A copy, because it runs the real logic
A test replaces the database with something the test controls. What is that replacement called?
- A stand-in behind a seam
- A second copy of the database
- A faster database server
A mock records which calls it received so the test can check them.
Circle one: True False
You want to check that your code asked the database for user 42. Stub or mock?
- A mock, because the test must inspect the call
- A stub, because canned rows are enough
- Neither, because databases cannot be replaced
You test a function that reads the current time. Where do you put the seam and why there?
- Inside the time formatting code, to test each line
- Around the clock itself, so the test controls time
- Inside the test runner, so all tests share one clock
A refactoring renames two helper functions and five tests fail, though behaviour is unchanged. What broke?
- The stand-ins returned the wrong canned answers
- The seam was placed at the boundary
- The tests assert on internal calls instead of results
Ana replaces the network with a mock and then asserts only on the final message shown to the user. A teammate says the mock is pointless. Is it?
- Yes, because mocks must always assert on calls
- No, because the mock still removes the slow network
- Yes, because only stubs can replace a network
Two designs: the code builds its own database connection inside, or it receives one from outside. Which survives refactoring better, and why?
- Receiving it, because the seam sits at the boundary
- Building it inside, because there are fewer parts
- Both equally, because seams do not matter