A Few Exercises for You to Practice Test-Driven Development (TDD)

Image for post
Image for post
Source: Xcode TDD Kata: Practice with the Bowling Game

From the TDD training class I attended last December, there were workshops with interesting exercises which I think it would be useful for everyone who new to TDD to practice or want explore the feeling of TDD.

There a lot of Kata for you to practice TDD out there. But if you don’t know which one to start with here you can take these as your first 3 exercises. Good luck and enjoy TDD!

TDD Exercises

Exercise 1 — FizzBuzz

This can be your first exercise to practice TDD. It is a good exercise for you to start and give you the real feeling of TDD. Don’t feel bad if you couldn’t do it well as this happens to everyone who start practicing TDD for the 1st time including myself :)

Exercise 2 — Roman Numbers

In this exercise, the implementation of the logic is not so obvious like in the exercise 1. Please use TDD approach to write your code and tests that are easy to understand, change, and maintain. You will also apply data-driven testing technique in this exercise.

Exercise 3 — Circular Buffer

In previous exercise 1 and 2, you write only 1 method to solve one single problem with obvious acceptance test cases. In this exercise, you will practice gathering requirements, writing acceptance test cases, and do a bit upfront design. You will also need to write several methods to make all the functionality work.

Note: Solutions in ABAP and Java are available now for exercise 1 and 2. Please check out the links on the exercise pages.

Originally published at pacroy.blogspot.com on January 21, 2017.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store