A brief look on Test Driven Development (TDD) - Ronald James

A brief look on Test Driven Development (TDD)

A brief look on Test Driven Development (TDD)

Test Driven Development (TDD)

Test Driven Development is one of the most effective practices from the agile community of practices, and also one of the least practiced regularly. Test Driven Development (TDD) means capturing the intent of the requirements in the form of a test case before starting to code. Test case could be a manual test case or an automated test script. Test case could be a functional or a user-acceptance or a unit test. TDD is generally a white-box unit-testing mechanism taking small steps prevents bugs and the need for debugging. Virtually every line of code is written in response to some failure. It often is a test failure, but might be a compilation failure, or a web page that does not exist.

Benefits of TDD

  • Maintainable – Traditional development styles produce products that face problem when the code is modified. Often, bugs are introduced at unexpected places which makes managers and developers hesitant to change functionality. However, if the major part of the project is covered by tests, assurance can be given that no unexpected bugs are introduced.
  • Clean interface/Code – The TDD method forces to work in a structured manner and to modify your code in small chunks, otherwise unit testing becomes complicated. The result is clean code that is well structured and easy to read.
  • Encouragement to the developer – It gives a developer the confidence that nothing breaks while changing or refactoring large applications.
  • Productivity – Overall, the amount of bugs in the project will be less and the bugs which are there can be resolved more easily. So although TDD requires an initial time investment, it will save time in the long run.

Importance of Refactoring in TDD

One important feature of TDD is Refactoring. According to the Refactoring concept, change the internal structure of the code without changing its external behavior. Refactoring is a key element of any agile process including TDD methodology. A trend analysis of the evolution of the design and implementation through successive refactoring iteration may give a hint on the probability to reach a stable architecture or component. It is quite conceivable to add design review of the component design during the development cycle to evaluate the stability of the implementation.

Value and Challenges

Value of TDD – especially in Agile

  • Tests are more explicit expression of requirements
  • Earlier defect detection by frequent testing
  • Ensures better coverage – don’t end up having superfluous code, without tests

Challenges – team resistance & reluctance?

  • ROI is realized in the long term – in maintenance phase
  • Extra coding effort seems unjustified in the beginning
  • Easier said than done- difficult to implement
  • Developer resistance

Steps in implementing TDD in an Agile Project

  • Have a requirement.  Let’s say “create a new login page for an online shopping”.
  • Think about what could be a reasonable test to verify compliance with the requirement.
  • Write the test before writing the code. Of course, the test will fail, and that’s ok.
  • Keep things simple.
  • Then, write only the minimally necessary code to make the test pass.
  • This is a process of discovery; as you identify possible improvements, refactor your code relentlessly to implement them.
  • Test, Fail, Build, Refactor and Increment and frequently run your cumulative collection of tests.


Test Driven Development takes time to master. It is conceptually simple, however, practicing test driven development on existing code, not written for tests tends to be very difficult.  And for some reason, even though there are some really great, and simple, techniques for working with legacy code, people tend to be unaware or unpractised with the well-known and well-documented techniques.

Thanks to Praveen Kumar for being our guest writer this week.

Book in for a free 10-minute candidate attraction call with us today? Please click here to make an appointment.

© Ronald James Ltd. 09824756. Q16 Business Exchange, Quorum Business Park, Newcastle upon Tyne, Tyne and Wear, NE12 8BX, United Kingdom. Website by Outlines Design.