Collecting TDD Katas

I'm not sure why I didn't have this idea earlier. The idea to collect TDD Katas here on this blog seems kind of obvious to me. But anyway, I've been fascinated by this idea ever since I saw the first Kata in Uncle Bob Martin's Clean Code video series. If I remember correctly, then I think I saw him do

Recently then, I ran into this blog post by Peter Provost called Kata - the Only Way to Learn TDD. This blog post mentions 2 TDD Katas, with an exact sequence of recommended tests which I would like to collect here for easier reference.

Before Peter goes into details about the Katas, he mentions the following advice, which also gives the blog post its title:"

Lately I’ve been asked by more and more people inside Microsoft to help them really learn to do TDD. [...] My guidance to them is simple. Do a TDD kata every morning for two weeks. Limit yourself to 30 minutes each morning. Then pick another kata and do it again.

Let's now look at the 2 Katas which he mentions in detail.

The Bowling Game Kata

Uncle Bob breaks this kata down into the following five tests:

  1. Gutter game scores zero - When you roll all misses, you get a total score of zero.
  2. All ones scores 20 - When you knock down one pin with each ball, your total score is 20.
  3. A spare in the first frame, followed by three pins, followed by all misses scores 16.
  4. A strike in the first frame, followed by three and then four pins, followed by all misses, scores 24.
  5. A perfect game (12 strikes) scores 300.

The String Calculator Kata

  1. An empty string returns zero
  2. A single number returns the value
  3. Two numbers, comma delimited, returns the sum
  4. Two numbers, newline delimited, returns the sum
  5. Three numbers, delimited either way, returns the sum
  6. Negative numbers throw an exception
  7. Numbers greater than 1000 are ignored
  8. A single char delimiter can be defined on the first line (e.g. //# for a ‘#’ as the delimiter)
  9. A multi char delimiter can be defined on the first line (e.g. //[###] for ‘###’ as the delimiter)
  10. Many single or multi-char delimiters can be defined (each wrapped in square brackets)