Dave Astels argues pretty strongly that though Test Driven Development is catching on, many people could still be practicing it better. One issue is the idea of one-to-one production classes to test classes:
“A lot of people have a mantra. We’ll have ClassX and ClassXTest.”
– Dave Astels
His point is well taken, and honestly I often fall into the trap of doing approximately one-to-one test to production classes. The brilliant advice is to:
“Have lots of little test classes. Should be building test classes around the setup or fixture that your building. That gets you a long ways towards BDD (Behavior Driven Development).”
— Dave Astels
So a code smell when writing unit tests is that you have tests that depend on the setup and tests that don’t use it or depend on another setup. This is a sign that you’re not testing just one behavior and you should refactor things out to two test classes.
A very simple idea, but very easy to recognize while you’re coding. (This advice comes from a talk he gave at Google, but its a very enjoyable talk for about 45 minutes on BDD)