This is very true, a bad test suite can be a very painful thing and extremely counter-productive
More importantly, the problem is not that a test itself is faulty. The problem is usually that you planned the wrong tests for your application. I’m always trying to think outside the box to figure out what I’ve missed in the application design and construction. That’s one reason a team is great, it gives you other people to bounce ideas off of.
This exactly who we do it here. We have high level discussion of how a feature is going to be designed, usually with some throw away diagrams on the white board.
This is a common problem in any design and forces you to design a little, code a little, design a little more, code a little more, etc. TDD however does a couple things that, in my opinion, actually make application design much harder.
I think having a design constantly evolving with a simplified means to dog-food if is one of the pluses of TDD. Would you care to share that couple of things that you think that TDD does that makes application design harder?
In TDD, however, you write low-level test after test which takes you so far down into the app that it’s hard to see the forest for the trees.
You can write TDD at any level of abstraction that suites you, and the CI server is designed to increase the awareness of the the health of the application team wide. If you not seeing the forest for the trees, then I think you might have bigger issues that TDD.
Then, as the sheer mass of tests you’re running continues to grow and as they all continue to return “successful” results, it tends to lull you into a VERY FALSE sense of security. I think these are two key flaws in TDD that for my money have sent me in other directions.
You have to lean to trust your test suite, if you don’t then your not going to the your ROI in it. The tests you wrote have to be testing the right thing and should constantly be refactored. If you have no faith or trust in your test suite, then you need the reasses your competency at writing tests. Blaming it on TDD with looking at how your writing tests isn’t going to help. We have a lot of tests, and I trust them when the are green and I know somerthing is broken when a test fails.
Does that mean that TDD is bad. No. I just prefer to plan out my testing checkpoints as part of my system design. This also gives me a good place in the design phase to do risk analysis and work risk mitigation plans into the design plan too. I do not find writing tests before coding to provide any particular advantage whether you’re programming solo or as part of a big team.
Just because you are practicing TDD does not mean you do no upfront design! We have a design phase, but its shorter and the resulting code is generally a fair bit different, but we have daily standups to discuss how we’re getting on, and are constantly reviewing each others code. TDD makes this process easier as a team mate can view code in isolation and use the unit tests generated by TDD as up-to-date documentation.
Bad design will kill you whether you’re writing bad code or bad tests first.
I think it’s easier to identify a bad design with TDD. If your tests are becoming difficult to write and maintain, your design is bad. Simple. TDD is easy, your designing your code with yours tests, nothing should be complicated or difficult. If it is, it’s time to review