3. What is TDD?
Test Driven Development is a software development process that relies on the
repetition of a very short development cycle: requirements are turned into very
specific test cases, then the software is improved to pass the new tests, only.
4. TDD Cycle
1. Write the test
2. Run the test (there is no implementation code, test does not pass)
3. Write just enough implementation code to make the test pass
4. Run all tests (tests pass)
5. Refactor
6. Repeat
5.
6.
7. String Sum Kata
Write a simple String Sum utility with a function string Sum(string num1, string
num2), which can accept only prime numbers and will return their sum. Replace
entered number with 0 (zero) if entered number is not a prime number.
Stat with a simplest test case with an empty string.
8. The FizzBuzz Kata
Write a program that prints the numbers from 1 to 100. But for multiples of three
print "Fizz" instead of the number and for the multiples of five print "Buzz". For
numbers which are multiples of both three and five print "FizzBuzz".
9. Why to do it?
Writing the tests first requires you to really consider what do you want from the
code
Fast feedback
Creates a detailed specification
Reduces time spent on rework
Less time spent in the debugger
Identify the error/problem quickly
Forces you to write small classes focused on one thing
Creates SOLID code
Cleans Interface
10. Why to do it?
Maintainable, Flexible & Easily Extensible
Shortens the development Time to Market
Increases the programmer’s productivity
Cuts development costs
Improves quality
Reduces bugs
11. Best practices
Pair programming
Prepare test plan
Test implementation should not take more than 15 minutes
Practice with coding dojos
Know your testing frameworks