Learning TDD using Kata's

0

Category : ,

Why We Need to Learn TDD?

Think of a scenario where a developer did complete unit testing and the Quality Assurance guys did their job and marked the deliverables ready for production. What happened if the other developer’s code/changes break the first developer’s code? Now, here we can think about TDD. As it is self-explanatory, Test Driven Development means what we are writing, we are testing. In this way, if someone broke your code, then your test(s) will get failed and you can check the broken area. This is just a one aspect, TDD is a huge one.

What is TDD?

As per wiki, TDD is defined as:
"Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards"



TDD has three stages called Red Green Refactor (RGR).

  • Red – First write test that fails.
  • Green – Modify/alter code so, test pass.
  • Refactor- Re-write the code better.

What is TDD Kata?

Kata is a Japanese word and means as ‘form’ and detailed choreographed pattern of body moments.
In martial arts, what they do, they do practice and repeat the steps to hone the skills and their patterns. Similarly, in software, the idea was originally invented by Dave Thomas. The motive of this idea is the same, do practice, repeat tasks and make your skills perfect.

The FizzBuzz Kata

Print the numbers from 1 to 100. But for multiples of three, print "Fizz” instead of the number and for the multiples of five, print "Buzz". For numbers which are multiples of both three and five, print "FizzBuzz".

Other Katas:

https://github.com/garora/TDD-Katas
http://tddkatas.codeplex.com/
http://codingkata.net/

My thanks to:
http://www.codeproject.com/Articles/886492/Learning-Test-Driven-Development-with-TDD-Katas