Reading all the explanations above, let me try to condense:
- Stub: a dummy piece of code that lets the test run, but you don't care what happens to it. Substitutes for real working code.
- Mock: a dummy piece of code that you verify is called correctly as part of the test. Substitutes for real working code.
- Spy: a dummy piece of code that intercepts and verifies some calls to real working code, avoiding the need to substitute all the real code.