Hacker News new | past | comments | ask | show | jobs | submit login

There's no argument over it Mocks are evil.



Evil enough that new mocks should be banned by fiat and enforced by code that requires rarely granted permission to override against projects that are 5 years old and already have hundreds of them in place and do not have architectures that support better ways of testing?

It might be a nice thing to avoid them, but you're always working with legacy code, and I've literally had "I need to add a button to accept new permissions" blow up into "I need to refactor our entire class structure across 200 files because I'm not allowed to add a new test that follows our old patterns nor commit this code without coverage, and oh yeah, nobody wants to review that CL in one go so I have to figure out how to break it into 20 bite sized changes. There goes my quarter...". That's just dumb, and that type of dumb is very fashionable at Google.


This is a vast oversimplification of mocks. Mocks themselves aren't evil, they just enable subpar programming. I'd much rather spend 2 minutes making a functional test with a mock than 2 days rewriting a bunch of core functionality in the name of code purity.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: