Writing Untestable Code

| Comments

The Google Testing Blog has a great post about how to write code that is impossible to test. The list is a handy scorecard to compare your work to. I was happy to see my sentiments about evil constructors echoed in one of the items:


Heavy Duty Constructors - Make constructors that do lots of work in them. The more work you do in the constructor, the hard it is to create your object in a test fixture. And if your constructor can construct other things that are hard themselves to construct, that’s even better! You want the transitive dependencies of every constructor to be enormous. Enormous is hard to get under test.
blog comments powered by Disqus