News for hackers. Stuff that matters.
Re:Property-based testing in practice [pdf] by stouset on Tuesday April 02, 2024 @11:08AM (#39906597)
> code is written to be testable first, maybe with lots of mocks

If you mean what I think I mean, this is the bottom rung of the ladder. Code that is only testable with lots of mocks is in practice worse than code with no tests.

Tests should do two things: catch undiscovered bugs and enable refactoring. Test mocked to high heaven do one thing: confirm that the code is written the way it’s currently written. This is diametrically opposed to and completely incompatible with those two stated goals. Most importantly, the code can’t be changed without breaking and rewriting tests.

Mocks are okay for modeling owners of external state. Even better are dummy/fake implementations that look and behave like the real thing, (but with highly simplified logic).

There are no comments on this comment yet.