A stub returns answers, a mock asserts expectations, and a fixture sets up the world the test runs in.
Aspect | |||
|---|---|---|---|
Purpose | Provide canned input | Verify interactions | Prepare known state |
Fails test on its own? | No | Yes, if expectation unmet | No |
Records calls? | No | Yes | No |
Typical use | Replace a dependency's return value | Assert a method was called | Seed a database, create files |
Origin of the term | Gerard Meszaros (test double) | Meszaros, popularized by Fowler | xUnit tradition |