FizzBuzz Kata
Implement the FizzBuzz kata to gain familiarity with the basics of the TDD approach.
We'll cover the following...
We’ll start practicing with the TDD approach. In this group of lessons, we’ll build a kata by following this technique. The example kata we are using is the FizzBuzz
kata.
Before starting, let’s review its rules. The FizzBuzz
function accepts an integer as a parameter, and it returns a string. The latter depends on the following conditions:
- If the number is divisible by three, it returns
Fizz
. - If the number is divisible by five, it returns
Buzz
. - If the number is divisible by three and five, it returns
FizzBuzz
. - If the number is neither divisible by three nor by five, it returns a string representation of that number.
In this kata, it’s clear that we have four requirements (or features) to implement. By implementing each of them with the TDD technique, we’ll gain familiarity with this approach and be ready to ...