3 ms·
I see this so often. Mocks and stubs get used all over the place because nobody understands what it means to write code that’s easily testable. They’re great w
by stouset 3y ago
I see this so often.
Mocks and stubs get used all over the place because nobody understands what it means to write code that’s easily testable. They’re great when used correctly (e.g., remote services or inherently stateful APIs like time). But they almost never are.
You end up with tests that ensure one and only one thing: the code is written the way it’s currently written.
Tests should do two things: find unexpected out-of-spec behavior, and prevent regressions during the course of editing and refactoring. These overly-mocked tests by definition can’t do the first one and they actively inhibit the second. They have negative value insofar as they constantly trigger failure while making completely benign edits.
- codethatwerks 3y ago[flagged]
- keybored 3y agoIt feels like - First write the needed change - Now assert that we just wrote the needed change