Member-only story
What is the Business Value of Unit Testing? Part 2
In the previous post, we started on a business application with the requirement:
As a user, I need a way to enter a number. Once the number has been entered, I need it to be printed back to me. The customer loves the app! But has a few new requirements for us:
As a user, I need a way to enter a number. Once the number has been entered, I need it to be printed back to me.
If a number evenly divisible by 3 is entered, the user should receive back “Fizz” rather than the number
If a number evenly divisible by 5 is entered, the user should receive back “Buzz” rather than the number
The requirements now are equivalent to the children’s problem and/or code kata FizzBuzz
Our code previously only had a single branch of logic. Get number, return number. Based on the new requirements, we can see there will be a few more branches:
- number is not evenly divisible by 3 or 5
- number is evenly divisible by 3
- number is evenly divisible by 5
- (not explicitly stated but) number is evenly divisible by both 3 and 5.
The 4th branch was not stated by the requirements, but seem like something that should be asked of the business owner, as it might not have been considered, or could have even been assumed.