Hacker News new | ask | show | jobs
by tigershark 3064 days ago
If you need to “over-parametrise” to make a class testable the problem is not in the unit test, it’s in your design.
1 comments

Exactly the kind of over-engineering I'm talking about.

The objective is to solve business problems, not write tests. Warping design to introduce unnecessary abstractions and indirections for testing is what leads to Java-itis, with factory factories.

This is exactly why I only ever test at the edges of a project, using mock systems that are as realistic as possible given time and resource constraints. The industry has an unhealthy obsession with ultrafast, ultra-unrealistic, low level unit tests that tightly couple to implementation details rather than behavior.

I don't think this is over-engineering though. Even if unit tests didn't warp designs they'd be a bad idea. I think it's just bad engineering based upon stupid dogma spread by the likes of J.D. Rainsberger and Uncle Bob.