What it really means is write code with no thoughts on design, patterns, or structure. This is sometimes interpreted as “return a hard-coded value” – but this is simplistic. You write minimal code to make the test green. You now have a requirement for the program. You make it compile, but ensure the test fails. You write a test that represents the behaviour that is needed from the system. Not a million miles away from the truth, but certainly not the complete picture. I thought it meant… “write a test, make sure it fails. Here is what I now believe to be the better way and this is what Ian opened my eyes to (and send to be what Kent Beck originally meant). It encourages you to do the wrong thing – or more specifically, it stops you from doing the right things. It is causing most of the pain we have with unit tests. Many sources, some of which are considered authorities, tell us to pair up our implementation class with a twin test class. I’m going to talk about the bit that I think is causing the real damage. You can seek him out for that (as an aside, please seek out a meet-up rather than just jumping out of a bush and confronting him). I’m not going to talk about everything Ian covered in his talk. A subtle difference in the method, though, is making an enormous difference to its effectiveness. It has enough in common with the original to sound real. The version of TDD that appears in many books, articles, and examples is this incorrect version. Arbitrary rules have been added that undermine the concept. a way that makes it worthwhile, has been lost over time. So what was it that caused such a flash-of-light realisation? What was I doing so wrong? Here’s the story, with all the credit going to Ian Cooper who opened my eyes to this issue. I have had an epiphany at – I’m embarrassed about some TDD techniques I have been using. I promised to write up the details of this after writing the following Tweet while listening to Ian Cooper talk on “TDD: Where did it all go wrong?” at DevSouthCoast in April.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |