DEV Community

Discussion on: Writing 'Testable' Code Feels Wrong

Collapse
 
marcinwosinek profile image
Marcin Wosinek

I'm maybe from 'TDD cool aid' camp. When I started writing tests, often I had to organize my code in a special way to make it testable. Now, with probably 8 years of doing mostly TDD, I like more the code that has many layers of abstraction that make it testable.

I like the idea of automated testing - delegating to the machine part of our work, and providing the working code & executable documentation for our colleagues or future selves. I agree that testing impacts the code design, and I agree that 'testability' isn't the best metric to evaluate code design quality. But I think that code quality is more an art then science, and in the end we all following personal preference.

I'm open to the idea that making code testable can make it worse; but in the cases I deal on daily basis (business web apps) I think having unit tests is worth the price.