top | item 46415423

(no title)

BoiledCabbage | 2 months ago

The whole mocks, fakes and the rest were always a terrible idea. Although people didn't realize it st the time, they were a band-aid to try to make poorly architected code testable.

90% of the time, needing to use a mock is one of the clearest code warning smells you have of there being an issue in the design your code.

It took a while, but the industry seems to be finally (although slowly) coming to this realization. And hopefully with it almost all of this can go away.

discuss

order

mangodrunk|2 months ago

I agree. Tests relying on mocks rarely uncover or prevent issues. They also typically make it harder to make changes. Very bad idea that should have been left behind years ago.

danparsonson|2 months ago

How do you substitute for dependencies that you're not testing, or that you want to deliberately break?

bluGill|2 months ago

90% of the time (or more): you don't. The real thing is perfectly fine in a test with the right setup. Fileio is fast, I just need a test file in a tempdir. databases are fast, I just need an easy way to settup my schema. Sometimes I need the isolation but normally I do not.

mangodrunk|2 months ago

Why substitute dependencies? Is the isolation worth it?

fud101|2 months ago

Ok, can someone explain this to someone with double digit iq? Is it validating the adapter idea or something else?