FizzBuzz: Not-Divisible Requirement
Add test scenarios to our FizzBuzz kata to better understand how to apply TDD.
As a reminder, let’s recap the rules of the FizzBuzz
kata. It’s a function that accepts a number as the input and returns a string depending 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.
So far, we managed the most trivial example which used 1
as the input argument. Now, let’s add more tests for the fourth requirement.
Passing 2
to the FizzBuzz
function
Let’s start with a simple scenario for the FizzBuzz
function, which consists of passing the value 2
to it.
The Red phase
Get hands-on with 1400+ tech skills courses.