Brian Richardson

Coding, traveling, etc.

TDD

During the talk on TDD (Test Driven Development) the loop of the TDD cycle was discussed. I realize some of you who have already read about this topic and are familiar with this cycle, but I just thought I would mention it.

The TDD Loop

  1. Write a small test for new functionality
  2. Write just enough code for the new functionality to pass the test
  3. Confirm that the revised system passes all tests
  4. Refactor to remove “code smells”
  5. Confirm that the revised system still passes all tests

So the question came up during the talk “How do you know how many tests to write?”. The answer to this question was “Write as many tests as you feel are necessary to feel confident that the code functions as it is supposed to”.  Developers are very good at writing positive tests (tests that show the code does what it is supposed to), however developers need to learn to get into the mindset of writing negative tests (tests that exercise conditions that should not happen but might).

TDD is extremely useful and important. Part of the problem pointed out with adoption is that if developers are just told to write unit tests and use TDD but are never given a good explanation of “Why” it can cause resistance to moving in this direction.

March 5, 2008 - Posted by Brian | Uncategorized | | No Comments Yet

No comments yet.

Leave a comment