TechnicalArchitectureWorx

The (Unofficial) ITWorx Technical Architecture Blog

Test Driven Development (TDD)

Posted by archworx on May 27, 2007

One of the basics in eXtreme Programing (XP) is to test any code that might break. In an approach to make life easier, developers wrote tests before writing the actual code!!

“It’s about figuring out what you are trying to do before you run off half-cocked to try to do it. You write a specification that nails down a small aspect of behaviour in a concise, unambiguous, and executable form. It’s that simple. Does that mean you write tests? No. It means you write specifications of what your code will have to do. It means you specify the behaviour of your code ahead of time. But not far ahead of time. In fact, just before you write the code is best because that’s when you have as much information at hand as you will up to that point. Like well done TDD, you work in tiny increments… specifying one small aspect of behaviour at a time, then implementing it.” – Dave Astels

The development cycle in TDD is called Test-Code-Simplify, and it looks like the following:

(“Extreme Programming Applied“, p159)

  1. Write a single test
  2. Compile it. It shouldn’t compile, because you haven’t written the implementation code it calls
  3. Implement just enough code to get the test to compile
  4. Run the test and see it fail
  5. Implement just enough code to get the test to pass
  6. Run the test and see it pass
  7. Refactor for clarity and “once and only once”
  8. Repeat

One Response to “Test Driven Development (TDD)”

  1. […] suited for test driven development cause it allows you to start by coding the tests, whereas the main benefit of MsTest is that it can […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: