Tags

Other

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 practised regularly. Test Driven Development (TDD) means capturing the intent of the requirements in the form of a test case before starting to code. The test case could be a manual test case or an automated test script. The 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 a 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 number 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 behaviour. 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 the 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 a 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.

Conclusion

Test Driven Development takes time to master. It is conceptually simple, however, practising 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.

Who Are Ronald James?

We are a leading niche digital & tech recruitment specialist for the North East of England. We Specialise in the acquisition of high-performing technology talent across a variety of IT sectors including Digital & Technology Software Development.

Our ultimate goal is to make a positive impact on every client and candidate we serve - from the initial call and introduction, right up to the final delivery, we want our clients and candidates to feel they have had a beneficial and productive experience.

Contact our Team

If you’re looking to start your journey in sourcing talent or find your dream job, you’ll need a passionate, motivated team of experts to guide you. Check out our Jobs page for open vacancies. If interested, contact us or call 0191 300 6501 for a quick chat with our team.

Let's be Friends!

Follow us on our blog, Facebook, LinkedIn, Twitter or Instagram to follow industry news, events, success stories and new blogs releases.

 

 

Back to Blog

</Follow Us>