The Programming Chronicles

Projects, Exercises and Examples

Fork me on GitHub

Test Driven Development Exercises
Step by Step Exercises and Examples to Learn Test Driven Development

The exercises are written in Java, but I think it would be easy to migrate to other languages. I tried to use basic JDK elements and avoid using any particular framework or library, except for the unit testing and mocking libraries.

The unit tests are written with JUnit 4.0 and the automatic mocking with Mockito. Even so there are some exercises that show you how to make unit tests or mocks without any framework or library such JUnit or Mockito.

The automatic build is made using Maven 2 and all the projects generate a lot of useful information - like a tutorial - with the mvn site command.

exercises Organization

Most of the exercises are about the implementation of an application called AddressbookWiki. I'll publish the description of this imaginary application as soon as possible. In short, you can think of it as an application to manage a global address book where anonymous people can create, modify, delete and read contacts. Everyone around the world can contribute to create the content of the biggest address book of the world through the magic of Web 2.0 Collective Intelligence.

The exercises are organized in several lessons and appendixes. Every lesson has its own readme file where you can look for the goals of the lesson. Each lesson is divided in several projects that shows individual steps of the incremental and iterative process of TDD. Some steps show very little increments, so they are micro-steps such as the implementation of a very little new behaviour, a very little refactoring after getting a green light and so on. Other steps show how the code look likes after several iterations of the TDD process.

There are some lessons or exercises that do not have anything to do with the AddressbookWiki application. They are isolated exercises showing an important an specific concept of the TDD methodology .

I'm so sorry, although all source code is written in English, the readme files and JavaDoc comments are written in Spanish, and they have important information like a tutorial.

Would you like to translate them to English? Just fork me on GitHub.

Documentation

All the projects - both lessons and exercises - are prepared to generate a maven site full of useful information. The readme files describe the intentions and solutions of the exercises and lessons. The functional source code and test source code are full of JavaDoc and non JavaDoc comments that explain different aspects of the TDD methodology in detail, the way TDD works, some hits and tips, and so on.

You can see here the full documentation

I have planned to generate an index with all that information to quickly locate the exercises that show specific concepts of the methodology, but the documentation is still in Spanish.

Downloads

You can download here the source code of the exercises in a compressed Archive

Source Repository

The source code is available in this GitHub Repository.

License

All exercises are licensed under the terms of the GNU General Public License, Version 3