Follow @RoyOsherove on Twitter

How not to do TDD

Update:

It seems that much further down in the book, they do cover a more minimalist and simplistic approach to make the tests pass. I was too quick to write, and did not look further in the book. I would recommend people to SKIP the first chapter of that book, and move directly to the “getting started” part. My apologies for the early-to-blame nature of this post. I will make a more concrete investigation next time. 

Here’s an excerpt from one of the first chapters of a new book about TDD in C# - what’s wrong with the following paragraph and following code?

 

The reason for the test failure (as shown by the highlighted text) is that you have not implemented the method. The next step is to write code to make this test pass: 

 

Found it? I’ll highlight the offending sentence:

The reason for the test failure (as shown by the highlighted text) is that you have not implemented the method.

yes. And then they go on to FULLY IMPLEMENT the whole method, in a non test driven way. This is the offending book. I would NOT recommend buying it, as it shows a clear lack of understanding many things. first, a test not compiling is not the same as failing. second, you don’t fully implement the most complicated way to solve something.  

For a good tdd book I’d instead recommend Kent Beck’s oldie but a goodie, and this good book. (get both, not one of them, as they complete each other each other)

TDD course in Oslo - August 2011

Video: Team Leadership in the Age of Agile