5. @enriquebarbeito
Test-Driven Development in a nutshell
Software Craftsmanship Alicante
Test-Driven Development in a nutshell (1/2)
Code Katas
Kata String Calculator
Show me the code
Key concepts
❏ XP practice stated in 2003.
❏ TDD = TFD + Refactoring
❏ TDD != testing, so it is most about software design
❏ Does not replace architecture or design
❏ It is also a development process with a repetitive cycle.
Repeat with me: red-green-refactor! All-Code-Is-Guilty.jpg
6. @enriquebarbeito
Test-Driven Development in a nutshell
Software Craftsmanship Alicante
Test-Driven Development in a nutshell (2/2)
Code Katas
Kata String Calculator
Show me the code
Key rules when doing TDD
❏ Ensure isolated specs
❏ Arrange. Act. Assert
❏ One verification per test/spec
❏ Write only one spec at a time
❏ Do not lose the green during a refactor step
❏ No debugging (neither output logging) TDD cycle
7. @enriquebarbeito
Code Katas
Software Craftsmanship Alicante
Test-Driven Development in a nutshell
Code Katas
Kata String Calculator
Show me the code
❏ Code exercise which helps you to hone your skills
through practice and repetition
❏ Simple problem, easy to practice, every day
❏ Experiment with solutions
❏ Focus on
❏ the process of writing the code
❏ naming test cases
❏ the red-green-refactor cyclekata.gif
8. @enriquebarbeito
Kata String Calculator
Software Craftsmanship Alicante
Test-Driven Development in a nutshell
Code Katas
Kata String Calculator
Show me the code
int Add(string numbers)
❏ The method can take 0, 1 or 2 numbers, and will return their sum (for an empty
string it will return 0) for example "" or "1" or "1,2"
❏ Allow the Add method to handle an unknown amount of numbers
❏ Allow the Add method to handle new lines between numbers (instead of commas).
❏ Support different delimiters.
❏ Calling Add with a negative number will throw an exception.
9. @enriquebarbeito
Show me the code
Software Craftsmanship Alicante
Test-Driven Development in a nutshell
Code Katas
Kata String Calculator
Show me the code
Demo