← Graph

Stubs over Mocks

concept 3 connections

Ivan Nemytchenko's test-double guidance. Stubs replace external things (services) so the test can run in isolation. Mocks verify how internal collaborators were called, which turns black-box tests into white-box tests coupled to the implementation's structure — any restructuring breaks the tests even when behavior is preferable. Prefer stubs; reach for mocks only when truly necessary.

category
practice
about
Stubs over Mocks concept
Recommends stubs for external collaborators and warns against mocks coupling tests to internal structure.
about
Stubs over Mocks concept
Second iteration stubs `rand` with `allow(...).to receive(:rand).and_return(...)` and the talk analyzes the tradeoffs of stubs and mocks.
recommends
Stubs over Mocks concept
Recommends stubs over mocks to keep tests behavior-based rather than structure-based.

Provenance

Read by
8 extractions