Clean Coder
Do you write unit tests?
Yes, of course!
Do you write them first?
Yes, I follow the three laws of TDD.
What is the difference in module structure between your tests and your code?
I create one test class per production class.
So if you have a production class named User you will have a test class named UserTest?
Yes, almost always.
So the structure of your tests, and the structure of your code are covariant.
Um. I suppose so, yes.
And so you are coupling the structure of your tests to the structure of your production code.
I hadn’t thought about it being a coupling before; but, yes, I suppose I am.
So when you refactor the class structure of your production code, without changing any behavior; do your tests all break?
Well, yes. Of course.
To read the full article click on the 'post' link at the top.