Srikanth Sastry

Stubs in Testing

๐ŸŒณ Evergreen ยท

Stubs replace inbound interactions from dependencies to the SUT by providing canned responses so the test controls what the SUT sees. The critical rule: do not assert on outbound calls to a stub. That call is an implementation detail. If a refactor caches a previously fetched value, asserting on the stub call causes test failures with no behavior change. This is over-specification.