Avoid testing implementation details, test behaviors

added by dpeterson
10/11/2011 6:25:23 PM

282 Views

Ian Cooper writes an excellent piece on avoiding test implementation details, concentrating on the Red, Green, Refactor cycle, and what actually requires testing. He goes on to explain how new classes are not triggers for new tests, but rather new requirements. Overall a well written article that distills some of the values Kent Beck's book: Test Driven Development. If you find yourself struggling with TDD, I'm sure this will clear things right up.


2 comments

vijayst
10/11/2011 9:31:23 PM
The trigger for writing a test is a new requirement, and not a new class added (during refactoring). The above statement from the post is debatable. In TDD, we are writing unit tests. If the refactored class is used multiple times, it makes sense to invest time in testing it well and making sure that it works well in all conditions.

dpeterson
10/11/2011 11:35:04 PM
That's probably true, but I think the author was trying to convey that in most cases we should try to be in the mindset that we are testing features, rather than just testing code for the sake of testing code. I fully agree with what you say, I just don't think the author was being quite so literal. For someone new to TDD, testing features is a good way to achieve good code-coverage without falling into the traps the author discusses.