TDD Introduction with Kata FizzBuzz
Transcript of TDD Introduction with Kata FizzBuzz
An Introduction to TDDBy Example
Test Driven Development• Rapid feedback
• Short development cycles
• Incremental design
• Reduced complexity
• Force you to think
• Confidence
Write a Failing
Test
Make the Test
Pass
Refactor
TDD
Red Green Refactor
Principles1. Don’t write any new code until you first have a
failing test.
2. Test everything that could “possibly” break.
3. BabySteps
How to Get to Green• Fake it till you make it
• Fake it - return what the test requires, nothing more
• Obvious - when the code to make the test pass is trivial
• Triangulation - write a second test forcing the ‘fake’ solution to be exposed as insufficient
Refactoring• DRY - Don’t Repeat Yourself
• Technical Debt
• Don’t Live with Broken Windows
• Refactor Early, Refactor Often
Refactoring• Rename variable/method
• Extract variable/method
• Inline variable
Code Kata• Tennis
• Bowling
• Roman Numerals
• Game Of Life
• …
The Rules of FizzBuzz• If number is divisible by 3, return “Fizz”
• If number is divisible by 5, return “Buzz”
• If number is divisible by 3 & 5, return “FizzBuzz”
• Otherwise, return the number
Let’s Develop FizzBuzz Kata
Further Reading
Further Reading
Further Reading