TDD Example - writing software spec and test cases
Before starting TDD, I need software spec and test cases. My goal is demonstrating software development process with a simple example:fizzbuzz problem. Here is software spec for fizzbuzz problem: 1. if given number is divided up by 3, print fizz. 2. if given number is divided up by 5, print buzz. 3. if given number is divided up by both 3 and 5, print fizz buzz. 4. otherwise, print given number. From software spec, you can easily derive test cases based on different outputs. In this case, function's behavior is driven test cases: 1. Print fizz when input is 3 2. Print buzz when input is 5 3. Print fizz buzz when input is 15 4. Print given number Don't get stressed by writing test spec at first. It does not have to be perfect. It can be always enhanced during TDD cycle. We can start to create ceedling project named "fizzbuzz_unittest" and create module named "fizzbuzz". Let's start to write test code based on simple...