Abhi's Experiments

Its a place to write about my professional experience and experiments

Test Driven Development

TDD is a software development process, where the programmer first write the automated tests for the feature and makes it fail (RED) then write the code for the feature and makes it pass (GREEN) then re-factor the code.
There are many tests frameworks are available. NUnit for .NET, JUnit for Java, RSpec for Ruby on Rails, unittest for Python, etc.

TDD makes the code more maintainable. The other person who is going to work on the code won't feel any fear to touch the code because if anything went wrong the tests will fail and he can find it quickly. TDD makes the programmer more focused. At a time he write code only to fix the the test fails.

There are two approaches in TDD: Outside-In approach and Inside-Out approach.

Outside-In approach is, first we write tests for the high level acceptance of the feature. To support this test there might be some tests which are very low level. So we write tests from High level to low level, and fix the failing tests from low level to high level. Once the High level test is passed you are done with the entire tests for that feature.

In Inside-Out approach we write test for the low level task of the feature. After writing tests for all the low level tasks and makes it pass, we will write tests for the high level or acceptance scenario.

To get more details on TDD in Extreme Programming Visit TDD - Extreme Programming

blog comments powered by Disqus
unittest - Unit Testing fra... >>
<< Xtreme Programming