Table of contents
Properties of the book
- Full name: Test-Driven Development by Example
- Author: Kent Beck
- ISBN: 978-0321146533
- Publisher: Addison-Wesley
- Publication Date: 2002-11-18
- Pages: 220
Overview
"Test-Driven Development by Example" is a book by Kent Beck, one of the creators of Agile and Extreme Programming (XP) methodologies. This book shows how to use TDD in practice by coding a common development task - a simple Money
class. It also covers a lot of topics around TDD, such as: how to write tests, how to refactor code, what patterns can be used in TDD and even how to code your own testing framework.
Organization
The book consists of 3 parts:
- "I. The Money Example" part shows how to code
Money
class with the use of TDD.- Step by step, Kent Beck shows how to write tests, how to refactor code and how to use patterns in TDD.
- This part consists of great examples of thinking ahead, decide what requirements the target code should meet, how to write tests for them and then how to implement the actual code.
- Examples in this part are written in Java and JUnit. It is the most practical part of the book.
- It is a good starting point for people who want to learn more about TDD.
- "II. The xUnit Example" part shows how to code your own testing framework.
- This part is written in Python and shows how to write tests for the testing framework itself.
- By doing this, the reader will learn of some internals of testing frameworks and the test lifecycle (setup, run, teardown).
- Of course, it is not likely that you will need to write your own testing framework, but this part is a great source of knowledge about testing frameworks.
- "III. Patterns for TDD" part consists of various patterns description and advices around TDD or software development in general.
- Isolated tests, mocks, stubs, assertions: are just a few of topics covered in this part.
- You'll find here advices even about your working place setup.
Who is this book for?
This book is for developers who understand why we need to cover our code with tests and want to learn how to do it in practice.
As my audience is mostly JavaScript developers, I can say that this book will be useful for them as well even though the examples are written in Java and Python.
Understanding of classes and OOP concepts is required to understand the examples in the book. Some basic knowledge of software design patterns will be helpful as well as they are not deeply explained in the book.
Final Thoughts
I read a lot of articles online about TDD back in the past. But I really wanted to read about TDD from the person who created it. It was really great to read about the way Kent Beck thinks and codes during solving real task.
The code in the book is simplified and, of course, it is not a fully real-world example and production-ready solution, but it is a great starting point for people who want to learn more about TDD.
I can recommend this book for people who want to try TDD in their projects. For people who already use TDD, this book can be a good source of knowledge about testing frameworks and patterns.